Hi guys,
Today, I am studying enter and exits in AFL, and I have a doubt. I am afraid I am not having a good understanding of how some reserved variables (buyprice, sellprice, shortprice and coverprice) really work.
Following example code is an extract of a Howard Bandy's book showing how to enter and exit at market work.
SetTradeDelays(0,0,0,0);
BuyPrice = C;
SellPrice = C;
MA1 = MA(C,5);
MA2 = MA(C,25);
Buy = Cross(MA1,MA2);
Sell = Cross(MA2,MA1);
and following code (another extract from the same author) shows how to enter with a limit order and exit with a market order.
SetTradeDelays(0,0,0,0);
BuyPrice = C;
SellPrice = C;
MA1 = MA(C,5);
MA2 = MA(C,25);
BuySig = Cross(MA1,MA2);
Buy = (Ref(BuySig,-1)==1) AND (L<0.99*Ref(C,-1));
BuyPrice = 0.99*Ref(C,-1);
Sell = Cross(MA2,MA1);
Please, English is not my first language and I'm new programming, so it could be possible I would not be interpreting his words correctly. If it is the case, it would be glad been warned.
There is a thing that misleads me. Why Dr Bandy use "BuyPrice = C" and "SellPrice = C" in the first code (enter at market) and "SellPrice = C" in the second one (exit at market)? I have done some probes backtesting both codes and comparing with the same ones erasing these instructions and I am getting the same results. I would think it would be not necessary to use them but I guess I am wrong. I mean, some reason must have.
So, I raise my doubt in another way... is necessary to use buyprice an sellprice if I am buying or selling at market? I guess it is, but I don't know why.
Thanks,