Reversal close on grid
When there is a trading system: when a trading signal occurs, it is necessary to close opposite positions, I use a universal code - a code that can close OR BUY positions OR SELL positions:
//+------------------------------------------------------------------+ //| Close positions | //+------------------------------------------------------------------+ void ClosePositions(const ENUM_POSITION_TYPE pos_type) { for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==InpMagic) if(m_position.PositionType()==pos_type) if(!m_trade.PositionClose(m_position.Ticket())) // close a position by the specified m_symbol Print(__FILE__," ",__FUNCTION__,", ERROR: ","BUY PositionClose ",m_position.Ticket(),", ",m_trade.ResultRetcodeDescription()); }
When there is a trading system: when a trading signal occurs, it is necessary to close opposite positions, I use a universal code - a code that can close OR BUY positions OR SELL positions:
Thank you Vlad, I will try this.
Thank you Vlad, I will try this.
I am not 'Vlad' - I am 'Vladimir'. (Help: these are two different male names)
I am not 'Vlad' - I am 'Vladimir'. (Help: these are two different male names)
Ok, sorry then.
Hi there, tried two different ways to close grid positions on reversal signal but result is disastrous, the entry condition is based on oscillators so the idea is quite simple: buy low and sell high.
As a grid, it could be that there are several positions into one direction and then it appears the opposite signal. Instead of a StopLoss, I'm looking to close positions in the wrong direction by "reversal close".
These are the lines:
When there are opened orders in both directions, close from the first one so then it would be only one opened order (last one which is new signal).
Also wrote into a forward counter loop through FIFO rules too but result is the same: curve going down.
Actually think there must be some flaw in this module cause in the right way there should be some profitable deals especially into the flat but the advisor is just closing losing orders.
Hope someone can help in this matter.