Symbol Equity

 

Hello, I want to calculate the equity for each symbol separately, but my current code calculates the overall account equity instead. For instance, if my trading bot handles multiple currency pairs, and I only want the equity for the EURUSD pair, what code should I use? Can someone assist me in fixing my code?

input double Balance             =1000;

double Profit;
double equity;
void OnTick()
  {


for(int i=PositionsTotal()-1; i>=0; i--)  // look all positions

{

string Currentsymbol=PositionGetSymbol(i);

if(PositionSelect(Currentsymbol))  Profit  = AccountInfoDouble(ACCOUNT_PROFIT);

  equity = Profit + Balance ;

 Comment( "Current Symbol Equity is :", equity);
    
   }
 }
 

Your topic has been moved to the section: Expert Advisors and Automated Trading

Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

You have been advised before, so please pay more attention to this in the future.

 
Sie Samuel Roland Youl:Hello, I want to calculate the equity for each symbol separately, but my current code calculates the overall account equity instead. For instance, if my trading bot handles multiple currency pairs, and I only want the equity for the EURUSD pair, what code should I use? Can someone assist me in fixing my code?

That is impossible! Account balance or equity is irrespective of symbol. It is an overall value.

All you can do is calculate the accumulated profit or loss associated with each symbol, regarding positions, be they closed or still open.

 
Fernando Carreiro #:

Your topic has been moved to the section: Expert Advisors and Automated Trading

Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

You have been advised before, so please pay more attention to this in the future.

I do apologize for my mistake, I will be carful next time. 

 
Fernando Carreiro #:

That is impossible! Account balance or equity is irrespective of symbol. It is an overall value.

All you can do is calculate the accumulated profit or loss associated with each symbol, regarding positions, be they closed or still open.

Thanks for your explanation, I now better understand the logic behind it.