I am actually trying to close intraday open Order.
Buy at morning open.
sell logic: IIf(today_morning_open > today_noon_close, today_noon_close,today_end_close)
But it is not working for me.
Following is my code.
OpenTime = ParamTime( "OPen Time", "09:30:00" );
NoonTime = ParamTime( "Noon Time", "15:00:00" );
EndTime = ParamTime( "END Time", "16:00:00" );
tn = TimeNum();
OpenBar = tn == OpenTime ;
NoonBar = tn == NoonTime;
EndBar = tn == EndTime;
timeOK = tn >= NoonTime AND tn <= EndTime;
BuyPrice = today_morning_open;
day_before_yesterday_close = TimeFrameGetPrice("C",inDaily,-2);//ValueWhen(EndBar,Close,3);
yesterday_morning_open = TimeFrameGetPrice("O",inDaily,-1);//ValueWhen(OpenBar, Open, 2);
yesterday_noon_close = ValueWhen(EndBar, ValueWhen(NoonBar, Open, 1),2);
yesterday_end_close = TimeFrameGetPrice("C",inDaily,-1);//ValueWhen(EndBar, Close,2);
today_morning_open = TimeFrameGetPrice("O",inDaily,0);//ValueWhen(OpenBar, Open,1);
today_noon_close = ValueWhen(EndBar,ValueWhen(NoonBar, Open, 1),1);
today_end_close = TimeFrameGetPrice("C",inDaily,0);//ValueWhen(EndBar, Close, 1);
SellPrice = IIf(today_morning_open > today_noon_close, today_noon_close,today_end_close);
Buy = Ref(Condition1,0) AND OpenBar;// AND OpenBar ;
Sell = timeOK;
Please guide..