Code: Select all
[IntrabarOrderGeneration = false];
Var:pass(false),openv(0);
if time = 0920 then begin
openv=OpenD(0);
pass=true;
end;
if (marketposition = 0) and (close > (openv+100)) and (pass=true) then
buy(NumToStr(openv,0)) next bar (openv +50) limit;
if time = 1600 then
pass=false;
SetExitOnClose ;
Instruments: I have test runned the program using two sets of data. (Both in 5mins resolution)
One provided by IB, another one I downloaded online in the format of ASCII Mapping(1min data)
Both symbols show the same issue.
Ive also tested on 1min resolution, so it seems that the problem happens to all chart resolutions too.
I observed this problem during a back test.
The aim of the program is: when the price reaches the [open price of the day +100] and falls back 50pts, then it will buy one contract.
The variable "Pass" is to make sure that the trade only occurs in between 0920 and 1600
I used the function OpenD to retrieve the open price of the day, but it doesnt seem to work all the time.
Code: Select all
buy(NumToStr(openv,0))
Sometimes it worked accordingly like in the following picture: But in the other times, it always return the open price of the day BEFORE instead.
Ived tried changing the time from 0920 to other times like 0921 or 1000, but still doesnt solve the problem Ive tried using different sessions of the symbol, including the default 24/7 and custom sessions(Mon to fri from 0915 to 1600)
Both shows the problem still.
Can anyone please help?
Thanks,
CY