It does not close all open positions

To add comments, please log in or register
Giorgio
98
Giorgio  
this code works when I use [OHCL 1 minute] in the strategy tester, but when I use [every tick] it stops working and some positions remain open
 for ( int conta= PositionsTotal ()- 1 ; conta>= 0 ; conta--)
        {
         string symbol= PositionGetSymbol (conta);
         ulong PositionTicket=( ENUM_POSITION_PROPERTY_INTEGER ) PositionGetInteger ( POSITION_TICKET );
         ulong magic= PositionGetInteger ( POSITION_MAGIC );
         if ( Symbol ()==symbol && magic==EA_MagicNumber)
            trade.PositionClose(PositionTicket, NULL );

        } 

if anyone can help me I'd be grateful :)

To add comments, please log in or register