How can I determine highest equity for last 10 candles?

 

Hi Ladies and gents

I would like to set the highest equity for the last 10 candles.  I was thinking that I can perhaps use Bars() or Time[] or TimeCurrent() to do this, but I do not know how.  How can I get the EA to store the highest Equity and let the highest equity (if applicable) on the 10th candle fall away?  I use this to set the highest Equity which works well, but it will save it indefinitely:

double Equityhigh=0.0;
//--------------------
if(NormalizeDouble(AccountEquity(),2)>Equityhigh){
      Equityhigh=NormalizeDouble(AccountEquity(),2);
     }

Maybe along this line????:

double Equityhigh=0.0;
datetime Equitytime=0;
//--------------------
if(NormalizeDouble(AccountEquity(),2)>Equityhigh){
        if(Equitytime>Time[9]){
           Equityhigh=NormalizeDouble(AccountEquity(),2);
           Equitytime=TimeCurrent();
          }
//But this will completely reset the Equity after every 10 candles, instead of storing it properly

Thanks for any help

 

trader3000: I was thinking

Maybe along this line????:

How can I get the EA to store the highest Equity and let the highest equity (if applicable) on the 10th candle fall away?

  1. No,  you were not. None of those things have anything to do with equity.
  2. There's no context with your posted code, if those are not global or static, you already know. it won't work. And since you already stated why it won't work, why did you waste our time posting it, twice?
  3. Create an array. Remember the highest. On a new bar shift values left.