I'm just starting to use Power Language and I'm having trouble writing the script.
The task is the following. I want to use 1-hour timeframe bars. I want a position to be opened at the specified time of this bar (inside the bar) when the condition is fulfilled.
The problem is that with the code like in the example, I can see opening positions on the history of the chart, but the script does not open positions in real-time when running "Automate Order Execution".
Please help me fix my code so that the script works correctly in real-time.
SCRIPT CODE
Code: Select all
IntrabarOrderGeneration = true]
//Intrabar trade available
Inputs:
StartTime(0630), //Start Time for Green Bar or Red Bar
ControlTime(0635);// Control Time for Green Bar or Red Bar
variables:
IntraBarPersist GreenBar(False),
IntraBarPersist myopen(0);
//TRIGGER = If 06:30am (PST) Market open- --------------
//(06:30am Pacific Standard Time, New York session opens)
If Time =StartTime then begin
myopen=open;
end;
//Green Bar identification
If ControlTime > StartTime then Begin
If Time =ControlTime then begin
GreenBar = close>myopen;
end;
//ENTRY = If after 06:30 am and Greenbar and Condiition1 then Buy market
If Time>=ControlTime and Time[1]<=ControlTime and GreenBar then begin
If marketposition=0 and CONDITION1 then Buy next bar at market;
end;