Download MetaTrader 5

Equity ( History )

To add comments, please log in or register
Vantages
148
Vantages 2014.12.28 06:01 

Hello. I hope someone could guide me with my code below.

This is different from AccountProfit for I need to track only the Equity

of my account, more often to profit side before closing all positions

in my portfolio.


Thanks.


//-------------------------------------------------------------------+
// Equity Function                                                              |
//-------------------------------------------------------------------+
   void Equity ( )
      {
         if ( AccountEquity ( ) <= StartingEquity ) return;
                for( int cnt = StartingEquity; cnt >= StartingEquity; cnt++ )
                  {
                     if ( AccountEquity ( ) >= StartingEquity * 1.1 )
                        {
                           if ( OrderClose ( OrderTicket ( ), OrderLots ( ), OrderClosePrice ( ), Slippage, clrNONE )  ) Print ( "Close order success" );

                                 else Print ( "Close order failed" );

                        }
                  }
       }

Vantages
148
Vantages 2014.12.28 07:04  

I also wrote in this way


void PositionCloseAll ()
    {
     for ( double eq = StartingEquity; eq <= StartingEquity*2; eq++ )
           {
            if ( AccountEquity() >= eq * 1.1 ||
                 AccountEquity() <= eq * 0.9 )
                 {
                  PositionClose();
                 }
           }
    }

To add comments, please log in or register