Mosy D.m:
hello,
in first compile my indicator work currect but when new candle come the indicator not working ..
but when recompile or change the timeframe indicator work on all candles .. but still not working on new candles;
please check the picture that i send ..
//+------------------------------------------------------------------+ //| 0practice.mq5 | //| Copyright 2022, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2022, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #property indicator_chart_window #property strict #property indicator_buffers 2 #property indicator_plots 2 #property indicator_label1 "ColorLine" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 1 #property indicator_label2 "ColorLine" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 double arrow[]; double arrow1[]; input bool low_bool = true; input bool high_bool = true; bool delete_old_indicator_data = true; int MA_handle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping Print("ChartIndicatorName :" , ChartIndicatorName(0,0,0)); // ChartIndicatorDelete(0,0,ChartIndicatorName(0,0,0)); //delete_old_indicator_data = true; Print("init "); SetIndexBuffer(0,arrow,INDICATOR_DATA); //PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,10); PlotIndexSetInteger(0,PLOT_ARROW,234); PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-20); // PlotIndexSetDouble(d,PLOT_EMPTY_VALUE,0); //--- Set the vertical shift of arrows in pixels SetIndexBuffer(1,arrow1,INDICATOR_DATA); //PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,10); PlotIndexSetInteger(1,PLOT_ARROW,233); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,20); // PlotIndexSetDouble(f,PLOT_EMPTY_VALUE,0); //--- Set the vertical shift of arrows in pixels MA_handle=iCustom(NULL,0,"0practice"); Print("MA_handle = ",MA_handle," error = ",GetLastError()); //--- 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[]) { ArraySetAsSeries(arrow,false); ArraySetAsSeries(arrow1,false); //--- static int r =0; Print("turn : " + r++); Print("handle :::: " + MA_handle); //--- Copy the values of the indicator Custom Moving Average to our indicator buffer CopyBuffer(MA_handle,0,0,rates_total,arrow); CopyBuffer(MA_handle,1,0,rates_total,arrow1); //--- If our attempt has failed - Report this // if(copy<=0) // Print("An attempt to get the values if Custom Moving Average has failed"); int limit = rates_total - prev_calculated; if(limit == 0)limit++; // delete_old_indicator_data if(delete_old_indicator_data) { for(int i=0;i<limit;i++) { arrow[i] = 0 ; arrow1[i] = 0 ; // Print("limit :" , 1111); } delete_old_indicator_data = false; } //... //iCustom(_Symbol,_Period,"0practice"); for(int i=0;i<limit;i++) { if(close[i] > open[i] && high_bool) { arrow[i] = high[i] ; // int copied=CopyBuffer(ma_handle,0,0,rates_total,arrow); } else if(close[i] < open[i] && low_bool) { arrow1[i] = low[i] ; }else { arrow[i] = 0 ; arrow1[i] = 0 ; } if(limit==1) { if(close[i+1] > open[i+1] && high_bool) { arrow[i+1] = high[i+1] ; arrow1[i+1] = 0; } else if(close[i+1] < open[i+1] && low_bool) { arrow1[i+1] = low[i+1]; arrow[i+1] = 0; } else { arrow[i+1] = 0 ; arrow1[i+1] = 0 ; } } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- } //+------------------------------------------------------------------+
Try this!!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hello,
in first compile my indicator work currect but when new candle come the indicator not working ..
but when recompile or change the timeframe indicator work on all candles .. but still not working on new candles;
please check the picture that i send ..