Help: How to close open positions at the end of the day

#1
Dear All I need Help Of u To create Code (AFL) For Close All (Buy/Sell) Open Position At End Of The Day

*1) Close All Open Position At End Of Trading Day
For Example:- If my Position Ya Last Signal in Sell Then Next Signal At End Of Trading session's Last Minuit is give Buy Signal And Same in opposite Side if my Position ya Last Signal In Buy Then Next Signal At End Of Trading session's Last Minuit Is Sell
*2) We can Set Closing Time As Our Choice by parameters
:):):):):):):)
 
Last edited:

mithoon

Active Member
#2
Hi,
I am trying to do the same,i was given.. no_trading = TimeNum() > 152000;
Buy = your rules AND NOT no_trading;
Sell = ..your rules..OR no_trading;
but it doesnt work.. any advice?
 
#3
Hi,
I am trying to do the same,i was given.. no_trading = TimeNum() > 152000;
Buy = your rules AND NOT no_trading;
Sell = ..your rules..OR no_trading;
but it doesnt work.. any advice?
Buy = your rules;
Sell = your rules OR TimeNum() > 152000;
 

mcxinvest

Well-Known Member
#4
Check if you want this....in this from parameter you can select if you want to close the position intraday or not.


TimeRange = ParamToggle("Time","No|Yes");
Starttime = Param("Starttime",100000,100000,235500,0);
Closetime = Param("Closetime",232000,100000,235500,0);
ExitToday = (Ref(DateNum(),1) > DateNum());

B1 = "Buy condition"

S1 = "Sell condition"

Sh1 = "Short Condition"

Co1 = "Cover Condition"


Buy = IIf(TimeRange==False,B1,B1 AND TimeNum() > Starttime AND TimeNum() < Closetime);
Sell = IIf(TimeRange==False,S1,S1 OR TimeNum() > Closetime OR ExitToday);
Short = IIf(Timerange==False,Sh1,Sh1 AND TimeNum() > Starttime AND TimeNum() < Closetime);
Cover = IIf(Timerange==False,Co1,Co1 OR TimeNum() > Closetime OR ExitToday);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);
 

Similar threads