Close all tickets TP virtual


Dear team

can help me ?

i use this in my bot to close particial when come same price, but how i close the sum all tickets 

i think is better when 50 dollar is come, close all tickets and iniciate a new cycle


ticket swap price magic number

1 -10 40  0001

+20 -30 0009

0 40 1212

close all because sum everything is 50

#include <Trade\PositionInfo.mqh>

#include <Trade\Trade.mqh>


CPositionInfo  m_position;             // object of CPositionInfo class

CTrade         m_trade;                // object of CTrade class

//--- input parameters

input double   InpProfitInMoney  = 50;  // Profit in money

   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
         double profit=m_position.Commission()+m_position.Swap()+m_position.Profit(); // NEED TO USE THIS 


Your topic has been moved to the section: Expert Advisors and Automated Trading — In the future, please consider which section is most appropriate for your query.

Improperly formatted code edited by moderator. In future, please use the CODE button (Alt-S) when inserting code.

Code button in editor