indicator plot nothing but compile with no error plz highlight my mistake
indicator plot nothing but compile with no error plz highlight my mistake
Hello
The direction of the arrays in the indicator goes from [0] having the oldest item to [rates_total-1] having the newest item.
So , you can remove the set as series stuff , access the referenced arrays directly , and change the + to - in the direction of the checks.
#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_type1 DRAW_ARROW #property indicator_color1 DodgerBlue #property indicator_width1 2 #property indicator_label1 "buy arrow" #property indicator_type2 DRAW_ARROW #property indicator_color2 Red #property indicator_width2 2 #property indicator_label2 "sell arrow" #define RESET 0 double buyarrow[], sellarrow[]; int OnInit(){ SetIndexBuffer(0,buyarrow,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0); PlotIndexSetInteger(0,PLOT_ARROW,233); PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,0); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); SetIndexBuffer(1,sellarrow,INDICATOR_DATA); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,0); PlotIndexSetInteger(1,PLOT_ARROW,234); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); string short_name="binary signal indicator"; IndicatorSetString(INDICATOR_SHORTNAME,short_name); return(INIT_SUCCEEDED); } 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[]){ for(int i = 0; i < rates_total; i++){ if(i>=4){ double openh1 =open[i-1];//iOpen(_Symbol,PERIOD_CURRENT,shift+1); double closeh1 =close[i-1];//iClose(_Symbol,PERIOD_CURRENT,shift+1); double openh2 =open[i-2];//iOpen(_Symbol,PERIOD_CURRENT,shift+2); double closeh2 =close[i-2];//iClose(_Symbol,PERIOD_CURRENT,shift+2); double openh3 =open[i-3];//iOpen(_Symbol,PERIOD_CURRENT,shift+3); double closeh3 =close[i-3];//iClose(_Symbol,PERIOD_CURRENT,shift+3); double openh4 =open[i-4];//iOpen(_Symbol,PERIOD_CURRENT,shift+4); double closeh4 =close[i-4];//iClose(_Symbol,PERIOD_CURRENT,shift+4); if((openh1<closeh1) && (openh2>closeh2) && (openh3>closeh3) && (openh4>closeh4)) sellarrow[i]=closeh1; if((openh1>closeh1) && (openh2<closeh2) && (openh3<closeh3) && (openh4<closeh4)) buyarrow[i]=openh1; } } return(rates_total); }
thanks sir for your reply but.....
your correction also not place arrow on chart there is some thing very strange to me that when i createobject on my code it work fine but when i try to set array in if() function it not place any thing .....................this new code work fine but array does not work
#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 0 #property indicator_type1 DRAW_ARROW #property indicator_color1 clrGreen #property indicator_width1 2 #property indicator_label1 "buy arrow" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrRed #property indicator_width2 2 #property indicator_label2 "sell arrow" #define RESET 0 double buyarrow[], sellarrow[]; int OnInit(){ SetIndexBuffer(0,buyarrow,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0); PlotIndexSetInteger(0,PLOT_ARROW,233); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-5); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); ArraySetAsSeries(buyarrow,true); SetIndexBuffer(1,sellarrow,INDICATOR_DATA); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,0); PlotIndexSetInteger(1,PLOT_ARROW,234); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,5); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0); ArraySetAsSeries(sellarrow,true); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); string short_name="binary signal indicator"; IndicatorSetString(INDICATOR_SHORTNAME,short_name); return(INIT_SUCCEEDED); } 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[]){ for(int i = 0; i < rates_total; i++){ int shift =iBarShift(_Symbol,PERIOD_CURRENT,time[i]); double openh1 =iOpen(_Symbol,PERIOD_CURRENT,shift+1); double closeh1 =iClose(_Symbol,PERIOD_CURRENT,shift+1); double openh2 =iOpen(_Symbol,PERIOD_CURRENT,shift+2); double closeh2 =iClose(_Symbol,PERIOD_CURRENT,shift+2); double openh3 =iOpen(_Symbol,PERIOD_CURRENT,shift+3); double closeh3 =iClose(_Symbol,PERIOD_CURRENT,shift+3); double openh4 =iOpen(_Symbol,PERIOD_CURRENT,shift+4); double closeh4 =iClose(_Symbol,PERIOD_CURRENT,shift+4); if((openh1<closeh1) && (openh2>closeh2) && (openh3>closeh3) && (openh4>closeh4)) { ObjectCreate(_Symbol,"sell"+TimeToString(time[i-1]),OBJ_ARROW_SELL,0,time[i-1],high[i-1]); ObjectSetInteger(0,"sell",OBJPROP_COLOR,clrRed); ObjectSetInteger(0,"sell",OBJPROP_WIDTH,5); }; if((openh1>closeh1) && (openh2<closeh2) && (openh3<closeh3) && (openh4<closeh4)) { ObjectCreate(_Symbol,"buy"+TimeToString(time[i-1]),OBJ_ARROW_BUY,0,time[i-1],low[i-1]); ObjectSetInteger(0,"buy",OBJPROP_COLOR,clrLime); ObjectSetInteger(0,"buy",OBJPROP_WIDTH,5); }; } return(rates_total); }
Hello
The direction of the arrays in the indicator goes from [0] having the oldest item to [rates_total-1] having the newest item.
So , you can remove the set as series stuff , access the referenced arrays directly , and change the + to - in the direction of the checks.
ohh sir you are great your code correction is absolute right
there is a mistake of me
thanks for help sir
indicator plot nothing but compile with no error plz highlight my mistake