ThemBonez: Can't figure out why it is not drawing the arrows when I apply it to a chart.
for (int i=1;i<=300;i++)
Your look back is 6. what happens if you don't have 306 bars available? Why recalculate all 300 bars every tick? Only the current bar is changing. Do it right.int counted = IndicatorCounted(); for (int i=Bars - 1 - MathMax(counted,6); i >= 0; i--)
SwingLoBar[i] = iLowest(Symbol(),0,MODE_LOW,i+6,i);
Why do you want to know the lowest bar from [0 .. 5] (6 bars) for bar 0, [1 .. 7] (7 bars) for bar 1, [2 .. 9] (eight bars) for bar 2, [100 .. 205] (106 bars) for bar 100, etc.?- Why do you expect to see the bar number (1, 2, 100 ... ) on a price chart (1.2345+-0.0100?)
This
for (int i=1;i<=300;i++) { if (High[i] < High [i+3] ) if (High[i+1] < High[i+3] ) if (High [i+2] < High [i+3] ) if (High [i+3] > High [i+4] ) if (High [i+3] > High [i+5]) if (High [i+3] > High [i+6]) SwingHiBar[i] = iHighest(Symbol(),0,MODE_HIGH,i+6,i);
Seems a long winded way to do it as you simply appear to be checking that the highest high is simply the middle of 7
I believe that you are attempting something like this
#property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot SwingHiBar #property indicator_label1 "SwingHiBar" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrDodgerBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot SwingLoBar #property indicator_label2 "SwingLoBar" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrLimeGreen #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- input parameters //--- indicator buffers double SwingHiBar[]; double SwingLoBar[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,SwingHiBar); SetIndexBuffer(1,SwingLoBar); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW SetIndexArrow(0,234); SetIndexArrow(1,233); //--- 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[]) { if(rates_total<8) return(0); int x; if(prev_calculated==0) x=rates_total-8; else x=1; for(;x>=1;x--) { if(iHighest(Symbol(),0,MODE_HIGH,7,x)==x+3) SwingHiBar[x+3]=High[x+3]; if(iLowest(Symbol(),0,MODE_LOW,7,x)==x+3) SwingLoBar[x+3]=Low[x+3]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
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
Hi,
I created this custom indicator to draw an arrow at Swing Hi's and Lo's.
Can't figure out why it is not drawing the arrows when I apply it to a chart.
Any ideas?
ThemBonez