function run()
{
set(PLOTNOW);
StartDate = 20100101;
EndDate = 20101231;
BarPeriod = 5;
vars close = series(priceClose());
vars sma13 = series(SMA(close, 13));
vars sma31 = series(SMA(close, 31));

if(crossOver(sma13, sma31)) enterLong();
if(crossUnder(sma13, sma31)) enterShort();

plot("sma13", sma13, MAIN, BLUE);
plot("sma31", sma31, 0, RED);
}

you'll find that a moving average crossover strategy loses money.

Last edited by felixfx; 11/13/19 10:05.