Open zeshansari opened 1 year ago
this code allow to open buy/sell position successfully but where i write code to close my open positions when candles are red/green on 1 minute chart so it will close my open positions, but this code is not working however it is not giving any error as well. code run smoothly, took buy/sell positions a the given levels but didn't close any position except it touch its given TP or SLO level which is not desired. code for closing position is below,
if self.high > self.previous_high:
open_positions = mt5.positions_get(symbol="USA500")
for position in open_positions:
if position.type == mt5.ORDER_TYPE_SELL:
result = mt5.order_close(position.ticket, position.volume)```
I have write python code to close buy/sell positions with condition. I have hedging account so I have to close all open buy/sell positions separately but It is not working. my code is below
is there any solution to close open buy/sell positions separately when required?