Indicator that shows Profit/Loss on a chart ?

Einloggen oder registrieren, um einen Kommentar zu schreiben
Martin Nicholson
223
Martin Nicholson  

Hi everyone,

Does anyone know of an indicator that simply displays the state of the chart in currency ? If for example my EUR/USD chart is €100,- in profit, then it should show in a predefined corner "€100,-". That's it, pretty simple ! There are indicators around, like "Sum Pips", but they display all kinds of stuff that doesn't interest me (time till candle closes, P/L in pips etc...), but I'm just interested in the monetary P/L.

Thanks for any hints !

lippmaje
603
lippmaje  
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   double profit=0;
   double points=0;
   int count=0;

   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==_Symbol && OrderType()<=OP_SELL)
        {
         profit+=OrderProfit()+OrderSwap();
         points+=OrderProfit()/_Point;
         count++;
        }
     }
   if(count>0)
      Comment("profit: "+DoubleToString(profit,2)+" ("+DoubleToString(points,0)+" points, "+(string)count+" trade(s))");
   else
      Comment("");
   return rates_total;
}
Vorsicht, ist nicht getestet, sollte aber so ungefähr stimmen. Das <=OP_SELL ist eine Abkürzung für entweder Buy oder Sell.
Martin Nicholson
223
Martin Nicholson  
Vielen Dank lippmaje !


Einloggen oder registrieren, um einen Kommentar zu schreiben