Hello everyone.
I'm here again.
Now I'm triying to understand a code, I think it's a good way to learn how to code in AFL, I get that code from a paper of JB. Darwood , Shorting supernovas, it's about get short in highly overbought stocks.
I've been copy the code and when I send it to backtest it don't works. My "friend" Amibroker says "error 701", that means "Missing buy/sell variable assignaments".
I tried to place into the code the variables buy and sell, equal to zero, and equal to true, but still with succes.
Anybody knows what's happend here?
here the paper: http://jbmarwood.com/wp-content/uploads/2015/12/Shorting-Supernovas.pdf
here the code:
SetOption("InitialEquity", 10000);
SetOption("MinShares", 0.01);
SetOption("MarginRequirement", 100);
SetOption("UsePrevBarEquityForPosSizing", True);
SetTradeDelays(1,1,1,1);
SetOption("MaxOpenpositions", 10);
SetOption("SeparateLongShortRank", True);
MOL=0;
MOS=10;
SetOption("Maxopenlong", MOL);
SetOption("Maxopenshort", MOS);
SetOption("Allowsamebarexit", True);
Numberpositions=10;
SetOption("Maxopenpositions", numberpositions);
SetPositionSize(1,spsShares);
PositionSize=-100/20;
SetOption("CommissionMode", 3);
SetOption("CommissionAmount", 0.02);
Delisting=GetFnData("delistingdate");
Thisislastbar= BarIndex()==LastValue(BarIndex());
Exitlastbar= DateTime()>=GetFnData("DelistingDate");
Cond= IIf(IsNull(delisting), 1, DateTime()<delisting);
Increase = 80;
Holdingtime=5;
Short = ROC(C,5)>Increase AND Cond AND OpenInt>2 AND OpenInt <20 AND V> 500000;
Cover= 0 OR thisislastbar OR exitlastbar;
Sellperiod= Holdingtime;
ApplyStop(stopTypeNBar, stopModeBars, sellperiod);
ApplyStop(stopTypeProfit, stopModePercent, 20, 1, 1);
ShortPrice= 0;
CoverPrice= 0;
Thanks to all.