I have been trying to modify the stochastic histogram indicator so whenever a bar appears above 0 then an arrow will be drawn on the chart to buy. Then whenever a bar appears below 0 then an arrow will be drawn on the chart to sell.
However, the indicator will not drawn the arrows. Here is the code:
I'm sure I am missing a pretty basic part, so could someone please tell why the arrows are not being drawn?
Thank you for your time!
I think these lines need to be within the for loop . . .
if(upB[shift] <= 0) Arrow_Dn[shift] = High[shift]; if(loB[shift] > 0) Arrow_Up[shift] = Low[shift];
I think these lines need to be within the for loop . . .
Thanks for the reply I appreciate the help but it still is not drawing the arrows.
Here is the updated version:
/* ********************************************************************* Bollinger Squeeze v8 Original code by Nick Bilak Modifications by Akuma99 Copyright © 2006-07 Akuma99 http://www.beginnertrader.com For help on this indicator, tutorials and information visit http://www.beginnertrader.com ********************************************************************* */ #property copyright "Copyright © 2006-07, Akuma99" #property link "http://www.beginnertrader.com " #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Gold //uptrend #property indicator_width1 2 #property indicator_color2 OrangeRed //downtrend #property indicator_width2 2 #property indicator_color3 Yellow // First Stochastic line #property indicator_width3 2 #property indicator_color4 Red #property indicator_color5 DarkKhaki extern string note1 = "First Stochastic"; extern int StochPeriod1=14; extern int DPeriod1=3; extern int SlowingPeriod1=3; double upB[]; double loB[]; double Stoch1[]; double Arrow_Dn[]; double Arrow_Up[]; //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,indicator_width1,indicator_color1); //uptrend SetIndexBuffer(0,upB); SetIndexEmptyValue(0,EMPTY_VALUE); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,indicator_width2,indicator_color2); //downtrend SetIndexBuffer(1,loB); SetIndexEmptyValue(1,EMPTY_VALUE); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,Stoch1); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,217); SetIndexBuffer(3,Arrow_Dn); SetIndexEmptyValue(3,0.0); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,218); SetIndexBuffer(4,Arrow_Up); SetIndexEmptyValue(4,0.0); //---- return(0); } //+------------------------------------------------------------------+ int deinit() { } //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int shift,limit; IndicatorShortName("Stoch Histogram ("+StochPeriod1+","+DPeriod1+","+SlowingPeriod1+")"); if (counted_bars<0) return(-1); if (counted_bars>0) counted_bars--; limit=Bars-31; if(counted_bars>=31) limit=Bars-counted_bars-1; for (shift=limit;shift>=0;shift--) { Stoch1[shift]=iStochastic(NULL,0,StochPeriod1,DPeriod1,SlowingPeriod1,MODE_SMA,0,MODE_MAIN,shift)-50; if(Stoch1[shift]>0) { loB[shift]= 0; upB[shift]=Stoch1[shift]; } else if (Stoch1[shift]<0){ upB[shift]= 0; loB[shift]=Stoch1[shift]; } if(upB[shift] > 0) Arrow_Up[shift] = Low[shift]; if(loB[shift] < 0) Arrow_Dn[shift] = High[shift]; } return(0); }
You also need to set this . . .
IndicatorBuffers(3); // <--- 5 buffers not 3
You also need to set this . . .
Yep that fixed it they are now drawing.
Thanks for the help!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have been trying to modify the stochastic histogram indicator so whenever a bar appears above 0 then an arrow will be drawn on the chart to buy. Then whenever a bar appears below 0 then an arrow will be drawn on the chart to sell.
However, the indicator will not drawn the arrows. Here is the code:
I'm sure I am missing a pretty basic part, so could someone please tell why the arrows are not being drawn?
Thank you for your time!