Hopefully people may find my comments useful if starting out.
So I have an array buffer(?) called height of type double. All I want to do is to get the current candle height and compare it to the previous 2.
I originally had it very similar to the Fractals mq5 file but realised very quickly that I did not understand it enough to make even a simple height array.
So the copyBuffer function does not work as it says "no one of the overloads can be applied to the function call". I am assuming this is because the ExtUpperBuffer is of type double?
I know the indicator buffer is useful because it saves previous calculations using prev_calculated and rates_total, to only update new values in the array. That's why I would like to use this.
All I am trying to do is to copy the upperBuffer into this buffer. So then at least it has something!! So if I can do that, surely I can minus each index in the array with a lowerBuffer!!
I don't know how to fix or improve this. I mean, surely there is an easier way?
I am struggling, so any help would be greatly appreciated. Thank you.
You are working with an INDICATOR. The indicator carries with it ALL ARRAYS:
//+------------------------------------------------------------------+ //| Accelerator/Decelerator Oscillator | //+------------------------------------------------------------------+ int OnCalculate ( const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[])
- You DO NOT NEED to use CopyBuffer.
Now clarify your question: what should the indicator draw? How many lines should the indicator draw?
You are working with an INDICATOR. The indicator carries with it ALL ARRAYS:
- You DO NOT NEED to use CopyBuffer.
Now clarify your question: what should the indicator draw? How many lines should the indicator draw?
Hi Vladimir, thank you for replying.
I'm sorry about my lack of knowledge. I need a height indicator but there isn't one available.
There is only high and low, so I wanted to make 2 new array with these values.
But how do I save the height values to it?
I want them to draw an up arrow when it satisfies this if statement:
if(high[i-2]<low[i-1] && low[i]<low[i-1 && height[i-2]<=height[i]){ height[i] = high[i] - low[i]; }
Thank you very much.
All the best,
little.trader
Hi Vladimir, thank you for replying.
I'm sorry about my lack of knowledge. I need a height indicator but there isn't one available.
There is only high and low, so I wanted to make 2 new array with these values.
But how do I save the height values to it?
I want them to draw an up arrow when it satisfies this if statement:
Thank you very much.
All the best,
little.trader
Formulate your condition more precisely. So far I have settled on this option:
if(low[i-2]<low[i-1] && low[i-1]>low[i]/* && high[i-2]<=high[i]*/) MyHighBuffer[i]=high[i];
Full code
//+------------------------------------------------------------------+ //| Custom High Arrow.mq5 | //| Copyright © 2020, Vladimir Karputov | //+------------------------------------------------------------------+ #property copyright "Copyright © 2020, Vladimir Karputov" #property version "1.000" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot MyHigh #property indicator_label1 "MyHigh" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrSpringGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input group "Arrow" input uchar InpCode = 175; // Arrow code font Wingdings) input int InpShift = 10; // Vertical shift of arrows in pixel //--- indicator buffers double MyHighBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,MyHighBuffer,INDICATOR_DATA); //--- define the symbol code for drawing in PLOT_ARROW PlotIndexSetInteger(0,PLOT_ARROW,InpCode); //--- set the vertical shift of arrows in pixels PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-InpShift); //--- Set as an empty value 0 PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if(rates_total<3) return(0); //--- int limit=prev_calculated-1; if(prev_calculated==0) { MyHighBuffer[0]=0.0; MyHighBuffer[1]=0.0; limit=2; } for(int i=limit; i<rates_total; i++) { MyHighBuffer[i]=0.0; if(low[i-2]<low[i-1] && low[i-1]>low[i]/* && high[i-2]<=high[i]*/) MyHighBuffer[i]=high[i]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Result:
Formulate your condition more precisely. So far I have settled on this option:
Full code
Result:
HI Vladimir,
Thank you so much for sending this to me! I'm going to try learn more about this and see how everything works. Thank you for all the comments also, they are very helpful.
All the best,
little.trader
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hopefully people may find my comments useful if starting out.
So I have an array buffer(?) called height of type double. All I want to do is to get the current candle height and compare it to the previous 2.
I originally had it very similar to the Fractals mq5 file but realised very quickly that I did not understand it enough to make even a simple height array.
So the copyBuffer function does not work as it says "no one of the overloads can be applied to the function call". I am assuming this is because the ExtUpperBuffer is of type double?
I know the indicator buffer is useful because it saves previous calculations using prev_calculated and rates_total, to only update new values in the array. That's why I would like to use this.
All I am trying to do is to copy the upperBuffer into this buffer. So then at least it has something!! So if I can do that, surely I can minus each index in the array with a lowerBuffer!!
I don't know how to fix or improve this. I mean, surely there is an easier way?
I am struggling, so any help would be greatly appreciated. Thank you.