Equity ( History )

 

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" );

                        }
                  }
       }

 

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();
                 }
           }
    }

Reason: