Array within if statement using bars, Time and iHighest to find Highs between 2 points. Can't figure out where i am going wrong ?

 

Hey i've been having some trouble getting this to work was wondering if anyone could give me some tips ?

Im basically just trying to figure out how to mark two points and then find the highest or lowest bars between them. So far i have something like this for highest point.


if(*insert if statement*){
               for(j=BarUpdate-1;j>0;j--){
                  Bar_Update_Array[j]=Bar_Update_Array[j-1];//scroll  values 
                  iiBUA[j]=iiBUA[j-1];//scroll index                 
              } 
               Bar_Update_Array[0]=Time[i]; // Store time of candle in array
               iiBUA[0]=d; //storing bar number   
         
          BarsBetween = Bars(NULL,0,Bar_Update_Array[0],Bar_Update_Array[1]); // Find how many bars between two times stored
          int TopBars = iHighest(NULL,0,MODE_CLOSE,BarsBetween,i); // Find bar number of highest close 
          ArrowPlot[i+BarsBetween] = Close[i+BarsBetween]; // Plot arrow on high point
              
    }

Its plotting arrows but in the wrong place and when i print values to check, they are way off anything i am looking for. Think i might be storing the values wrong ? or perhaps i should cycle BarsBetween and TopBars into an array as well. Technically to store two points of interest the if statement has to come around twice and then it will have two points to work with. 

Any tips would be appreciated thank you :)

 
torexvir:

Hey i've been having some trouble getting this to work was wondering if anyone could give me some tips ?

Im basically just trying to figure out how to mark two points and then find the highest or lowest bars between them. So far i have something like this for highest point.


Its plotting arrows but in the wrong place and when i print values to check, they are way off anything i am looking for. Think i might be storing the values wrong ? or perhaps i should cycle BarsBetween and TopBars into an array as well. Technically to store two points of interest the if statement has to come around twice and then it will have two points to work with. 

Any tips would be appreciated thank you :)

https://stackoverflow.com/help/mcve

How to create a Minimal, Complete, and Verifiable example - Help Center
How to create a Minimal, Complete, and Verifiable example - Help Center
  • stackoverflow.com
When asking a question about a problem caused by your code, you will get much better answers if you provide code people can use to reproduce the problem. That code should be… …Minimal – Use as little code as possible that still produces the same problem …Complete – Provide all parts needed to reproduce the problem in the question itself...
Reason: