Any Ideas how to limit the re-draw in this indicator

 

Hi All,

 

working on optimizing some indicators and an EA that ive been working on for some time. In strategy tester it is so slow its quicker to forward test it at times lol

 

I think the main problem is with the fib scale indicator it re-draws on every tick and really it only needs to re-draw when a new high value or low value is set. or a previous high or low value drops out of the range of BarsBack.

 

I was thinking perhaps a simple If Function would do it but when I looked at it i couldnt find a way to make it work for more than if it was Bar 0 setting a new high or low.

 

The thing with it it sets Buffer 1 and Buffer 8 as the 2 extreme values. and basically if Low Value or High Value equals either Buffer 1 or Buffer 8 then the calc needs to happen and the window re-drawn at no other time does it need to do it. 

  int LowBar = 0, HighBar= 0;
  double LowValue = 0 ,HighValue = 0;
  
  int lowest_bar = iLowest(NULL,0,MODE_LOW,BarsBack,StartBar);
  int highest_bar = iHighest(NULL,0,MODE_HIGH,BarsBack,StartBar);
  
  
  double higher_point = 0;
  double lower_point = 0;
  HighValue=High[highest_bar];
  LowValue=Low[lowest_bar];
  
//Code Idea If Highest bar equals 0 or something similiar///

  If(highest_bar = 0  || lowest_bar = 0 )
  
  {
// But this wouldnt take into account if say Bar 22 was the previous high this dropped out the 24 bar range then bar 21 became the new highest bar//
  if(highest_bar < lowest_bar)

 

 Any help would be greatfully appreciated.