Question about High/Low level

 

Hey friends, I am a newbie to study coding.

This day I find a interesting indicator of draw high/low lines,"HighLowBands.mq4".

   i=Bars-LookBackPeriod+1;
   if(counted_bars>LookBackPeriod-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      UBBuffer[i]=High[iHighest(NULL,0,MODE_HIGH,LookBackPeriod,i)];
      LBBuffer[i]=Low[iLowest(NULL,0,MODE_LOW,LookBackPeriod,i)];      
      i--;
     }

the view is like this:

Now my question is :

As the document said, iHighest/ilowest is only can be apply to price(high low open close) & VOLUME & time

How can I apply it to a move avarage line so I can get a pic like this (draw use other software ):


Can somebody kindly help me,please?

Files:
 
thothapis:

Hey friends, I am a newbie to study coding.

This day I find a interesting indicator of draw high/low lines,"HighLowBands.mq4".

the view is like this:

Now my question is :

As the document said, iHighest/ilowest is only can be apply to price(high low open close) & VOLUME & time

How can I apply it to a move avarage line

Code your own version of iHighest and iLowest that you apply to the section of the MA buffer that you want . . .
 
RaptorUK:
Code your own version of iHighest and iLowest that you apply to the section of the MA buffer that you want . . .

But I don't know how to write the algorithm "iHighest /iLowest ",can you help me finish this function ?
 
thothapis:

But I don't know how to write the algorithm "iHighest /iLowest ",can you help me finish this function ?
Sure, how far have you got ? show what you have so far . . .
 
RaptorUK:
Sure, how far have you got ? show what you have so far . . .

for test,I modify a code to ge follow result:

get the highest of MA 30 at the period 30 bar:

 Buffer1[i]=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,iHighest(NULL,0,iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,i),30,i));

but it is not show correct result.

what 's wrong?

 
You need to write code to perform a similar function to iHighest & iLowest . . . you cannot use iHighest and iLowest.
 
RaptorUK:
You need to write code to perform a similar function to iHighest & iLowest . . . you cannot use iHighest and iLowest.


OMG,that is it.

I have no idea about how to code it?

A loop? add flag check?

Can you kindly help me ?

 
thothapis:
I have no idea about how to code it?
Can you kindly help me ?
  1. No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
  2. Buffer1[iPos] = ima(... iPos)
    Buffer2[iPos] = buffer1[ iHighestOnArray(Buffer1, Len, iPos) ];
    /////
    int iHighestOnArray(double B[], int len, int iPos){
        int iLimit = MathMinI(iPos + len, ArraySize(B)) - 1;
            iMax   = iLimit;
        while (iPos < iLimit){ 
            if (B[iMax] < B[iPos]) iMax = iPos;
            iPos++;
        }
        return(iMax);
    }
    int MathMinI(int a, int b){ if (a < b) return(a); return(b); }

 

As a newbie,what I want is to study something.

please do not say "slave" somewhat.

thank you WHRoeder.

I will try it

 
// i=Bars-LookBackPeriod+1;
// if(counted_bars>LookBackPeriod-1) i=Bars-counted_bars-1;
// while(i>=0)

int counted_bars = IndicatorCounted();
if (counted_bars < LookBackPeriod)  counted_bars = LookBackPeriod;
for(int iPos = Bars - 1 - counted_bars; iPos >= 0; iPos--){
    :
Reason: