I have some problems using the strategy position reserved words. My strategy uses al lot of opening orders with the "this bar on close" order action. In the same strategy code, after the code of these order statement(s) I want to use the strategy position reserved words: marketposition, barssinceentry, barssinceexit, entryprice and exitprice but they don't give me the right results. This simple code shows what I mean. In the code of "LE 1" I want the strategy results of the preceding buy but I get the wrong results. On the next bar the results are ok.
I studied very hard on all the EL documentation but I can't explain these results. Can you?
With regards,
Rob.
Code: Select all
if BarNumber = 1 then print(time, " ***");
if BarNumber = 2 then
begin
buy this bar on Close;
print(time, " LE 1. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1));
end;
if BarNumber = 3 then print(time, " NO 2. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1));
if BarNumber = 4 then begin sell 2 contracts this bar on close; print(time, " LX 3. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1)); end;
if BarNumber = 5 then print(time, " NO 4. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1));
if BarNumber = 6 then
begin
sellshort 2 contracts this bar on close;
print(time, " SE 5. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1));
end;
if BarNumber = 7 then print(time, " NO 6. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1));
if BarNumber = 8 then
begin
buytocover 2 contracts this bar on close;
print(time, " SX 7. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1)); end;
if BarNumber = 9 then print(time, " NO 8. EntryPrice: ", EntryPrice, " ExitPrice: ", ExitPrice(1), " Open: ", Open, " Close: ", Close, " mp: ", marketposition, " Barssinceentry: ", barssinceentry, " Barssinceexit: ", barssinceexit(1));