I'm trading forex and trying to add some price tracking such as spread and slippage, you know so I can keep a close eye on my broker
The basis of my code is as follows:
Code: Select all
[IntraBarOrderGeneration=true];
Var:
Intrabarpersist EntryBid(0),
Intrabarpersist EntryAsk(0);
if marketposition = 0 and condition1 = true then being
buy next bar
if EntryBid = 0 then EntryBid = close;
if EntryAsk = 0 then EntryAsk = close data[2]
end;
if marketposition = 1 then begin
if EntryBid <> 0 then begin
Alert(Text(EntryBid, " / ", EntryAsk);
EntryBid = 0;
EntryAsk = 0;
end;
end;
Now what's happening is I apply this code to a chart and using print I can see the code is working. Then when I turn on autotrade the first trade that happens returns the EntryBid and EntryAsk of the very first trade that happened on the chart in back test mode! Why!? But then the next trade that happens reports the correct EntryBid and EntryAsk.
I must be doing something stupidly wrong here :S