Code: always display 'Arrow' on the very RIGHT bar.
//+------------------------------------------------------------------+ //| High Arrow.mq5 | //| Copyright © 2021, Vladimir Karputov | //| https://www.mql5.com/en/users/barabashkakvn | //+------------------------------------------------------------------+ #property copyright "Copyright © 2021, Vladimir Karputov" #property link "https://www.mql5.com/en/users/barabashkakvn" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot High #property indicator_label1 "High" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input int Input1=9; //--- indicator buffers double HighBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,HighBuffer,INDICATOR_DATA); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW PlotIndexSetInteger(0,PLOT_ARROW,159); //--- 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[]) { //--- int limit=prev_calculated-1; if(prev_calculated==0) limit=0; for(int i=limit; i<rates_total; i++) { if(i==rates_total-1) HighBuffer[i]=high[i]; else HighBuffer[i]=0.0; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Result:
Thanks you for your help.
I was wrong, I thought ArraySetAsSeries() will also reverse the array order, into like MT4.
It does reverse the order, what was missing is an ArraySetAsSereis for extSARBuffer (preferably in OnInit for that case), so your code was drawing the arrow at the 2nd candle on the left end at the high of the 2nd candle on the right end
It does reverse the order, what was missing is an ArraySetAsSereis for extSARBuffer (preferably in OnInit for that case), so your code was drawing the arrow at the 2nd candle on the left end at the high of the 2nd candle on the right end
That explained everything. Thanks a lot, appreciate it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use