Rj_Sliding Range mq4

#1
Hello all,
Would anyone be kind enough the convert the mq4 code below into Amibeoker Code
Thank you in advance

Derek
Code:
//+------------------------------------------------------------------+
//|                                              Rj_SlidingRange.mq4 |
//|                            Copyright © 2011,RJ Rjabkov Alexander |
//|                                                     [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011,RJ Rjabkov Alexander"
#property link      "[email protected]"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 Red
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 2
#property indicator_style1 2
#property indicator_style2 2

extern int CalcPeriodRange  = 5;

double UpperLimit[];
double LowerLimit[];
double AwlUpper[];
double AwlLower[];
double Current[];

int init() {
  IndicatorBuffers(5);
  SetIndexBuffer(0, UpperLimit);
  SetIndexBuffer(1, LowerLimit);
  SetIndexBuffer(2, AwlUpper);
  SetIndexBuffer(3, AwlLower);
  SetIndexBuffer(4, Current);
  SetIndexStyle(0, DRAW_LINE);
  SetIndexStyle(1, DRAW_LINE);
  SetIndexStyle(2, DRAW_LINE);
  SetIndexStyle(3, DRAW_LINE);
  return(0);
}

int deinit() {return(0);}

int start() {
  int i, cb;
  int counted_bars = IndicatorCounted();
  if (counted_bars < 0) return(-1); 
  if (counted_bars > 0) counted_bars--;
  cb=Bars-counted_bars;

  while(cb>=0) {
    i=cb+CalcPeriodRange-1;
    double b1=0, b2=0;
    while(i>=cb) {
      b1 += High[iHighest(NULL, 0, MODE_HIGH, CalcPeriodRange, i)];
      b2 += Low[iLowest(NULL, 0, MODE_LOW, CalcPeriodRange, i)];
      i--;
    }
    UpperLimit[cb]=b1/CalcPeriodRange;
    LowerLimit[cb]=b2/CalcPeriodRange;
    Current[cb]=NormalizeDouble((UpperLimit[cb]+LowerLimit[cb])/2, 5);
    AwlUpper[cb]=EMPTY_VALUE;
    AwlLower[cb]=EMPTY_VALUE;
    if(Current[cb]>Current[cb+1]) {AwlUpper[cb]=Current[cb]; AwlUpper[cb+1]=Current[cb+1];}
    if(Current[cb]<Current[cb+1]) {AwlLower[cb]=Current[cb]; AwlLower[cb+1]=Current[cb+1];}
    if(Current[cb]==Current[cb+1] && AwlLower[cb+1]!=EMPTY_VALUE) {AwlLower[cb]=Current[cb];}
    if(Current[cb]==Current[cb+1] && AwlUpper[cb+1]!=EMPTY_VALUE) {AwlUpper[cb]=Current[cb];}
    cb--;
  }
  return(0);
}
//+------------------------------------------------------------------+
 

trash

Well-Known Member
#3
So where are you stuck?
The upper band is the MA of HHV.
The lower band is the MA of LLV.
The mid line is the average of those two ones.
Then you have three Plot() lines to plot those upper variables.
All together -> 6 lines of AFL code vs. trillions of lines of MT4 code.
I think you do get that one done easily, don't you.
 
#4
So where are you stuck?
The upper band is the MA of HHV.
The lower band is the MA of LLV.
The mid line is the average of those two ones.
Then you have three Plot() lines to plot those upper variables.
All together -> 6 lines of AFL code vs. trillions of lines of MT4 code.
I think you do get that one done easily, don't you.
I don't think that man can code which is why he maybe asking for help.
Think he just copied the mt4 code and wants an afl because he uses Ami.
 

trash

Well-Known Member
#5
It doesn't matter whether he can or can't code. It is not my "problem" to solve. You seem to miss the fact that he already got all help that is required in order to get him started. All mentioned four functions are laid out in very detail in the AB manual. As aside if he is not amibroker member then he should help himself anyway.
 
#6
It doesn't matter whether he can or can't code. It is not my "problem" to solve. You seem to miss the fact that he already got all help that is required in order to get him started. All mentioned four functions are laid out in very detail in the AB manual. As aside if he is not amibroker member then he should help himself anyway.
It is fine sir. Sometimes, some people need more help than others. If you can help him yet again, kindly do so. Else, let us wait and hope some other kind soul on this forum will take the lead.

I see you have been very helpful fixing coding problems for others. I appreciate it!!
 

Similar threads