Help! Why does my indicator draw vertical lines on the main chart for unassigned lower window technical's !?
see code attached...thanks
//+------------------------------------------------------------------+ //| Scalp7.mq4 | //| Copyright 2015, Ferrari Green Associates | //| https://www.Ferrari-Green.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Ferrari Green Associates" #property link "https://www.Ferrari-Green.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 6 //---Indicator Colours #property indicator_color1 clrGreen//up arrow #property indicator_color2 clrRed//down arrow #property indicator_color3 clrCrimson//bollinger #property indicator_color4 clrBlue//bollinger //#property indicator_color5 clrWhite//bollinger //#property indicator_color6 clrWhite//bollinger //---Indicator Width #property indicator_width1 2 #property indicator_width2 2 #include <WinUser32.mqh> extern bool show=true;//Show Indicators? double UpArrow[]; double DownArrow[]; double Ema40[]; double Ema80[]; double CCI[]; double CCIback[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,UpArrow); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,233); SetIndexLabel(0,"Buy Signal."); //--- SetIndexBuffer(1,DownArrow); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,234); SetIndexLabel(1,"Sell Signal."); //--- SetIndexBuffer(2,Ema40); SetIndexStyle(2,DRAW_LINE); SetIndexLabel(2,"Ema40"); //--- SetIndexBuffer(3,Ema80); SetIndexStyle(3,DRAW_LINE); SetIndexLabel(3,"Ema80."); //--- SetIndexBuffer(4,CCI); SetIndexStyle(4,DRAW_LINE); //--- SetIndexBuffer(5,CCIback); SetIndexStyle(5,DRAW_LINE); 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[]) { //---for loop int counted_bars=IndicatorCounted(); int limit= Bars-counted_bars; for(int i=1;i<limit;i++) { double Ma40=iMA(NULL,0,40,0,MODE_EMA,PRICE_MEDIAN,i); double Ma80=iMA(NULL,0,80,0,MODE_EMA,PRICE_MEDIAN,i); double Com=iCCI(NULL,0,21,PRICE_MEDIAN,i); double ComBack=iCCI(NULL,0,21,PRICE_MEDIAN,i+1); //--- double PriceMedian=(High[i]+Low[i])/2; double PriceAll=(High[i]+Low[i]); double PriceHigh=(High[i]); double PriceClose=(Close[i]); if(show==true) { Ema40[i]=Ma40; Ema80[i]=Ma80; CCI[i]=Com; CCIback[i]=ComBack; } if(Ma40>Ma80) if(Com>0 && ComBack<0) { UpArrow[i]=Open[i]; } // if() { // DownArrow[i]=Open[i]; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
With a small amount of code, it is useful to post the code using SRC button. I have added it for you.
#property indicator_chart_window
means that the buffers are drawn in the main chart window.
Values such as CCI will often appear as vertical lines
does this effect the final signal outcome?
double CCI[]; double CCIback[];
seems to me that you don't use these 2 buffers for anything as the CCI calculations are done with variables. As you don't want lines drawn for them, you may as well remove them completely. If you intend to use them in further development of the code, you could set them to DRAW_NONE.
and what happens if I remove #property indicator_chart_window will this effect the visual view?
Probably that is the default and removing it will not solve your problem.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Any suggestions as to why would be appreciated.
regards ........