- iHighest error 4051
- Coding help
- Modifying a simple indi?
Zarod Allen:
#property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Lime // Swing High color #property indicator_color2 Red // Swing Low color extern int lookbackBars = 10; // Number of bars to look back for swing high/low identification double swingHighBuffer[]; double swingLowBuffer[]; int CustomIndicatorCounted() { return Bars - lookbackBars; } 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[] ); { int limit = rates_total - lookbackBars; if (prev_calculated > 0) limit--; for (int i = limit; i >= 0; i--) { double highPrice = high[i]; double lowPrice = low[i]; bool isSwingHigh = true; bool isSwingLow = true; for (int j = 1; j <= lookbackBars; j++) { if (high[i + j] >= highPrice || low[i + j] <= lowPrice) { isSwingHigh = false; isSwingLow = false; break; } } if (isSwingHigh) { for (int k = 1; k <= lookbackBars; k++) { if (high[i - k] >= highPrice || high[i + k] >= highPrice) { isSwingHigh = false; break; } } if (isSwingHigh) { swingHighBuffer[i] = highPrice; swingLowBuffer[i] = EMPTY_VALUE; } else { swingHighBuffer[i] = EMPTY_VALUE; swingLowBuffer[i] = EMPTY_VALUE; } } else if (isSwingLow) { for (int l = 1; l <= lookbackBars; l++) { if (low[i - l] <= lowPrice || low[i + l] <= lowPrice) { isSwingLow = false; break; } } if (isSwingLow) { swingHighBuffer[i] = EMPTY_VALUE; swingLowBuffer[i] = lowPrice; } else { swingHighBuffer[i] = EMPTY_VALUE; swingLowBuffer[i] = EMPTY_VALUE; } } else { swingHighBuffer[i] = EMPTY_VALUE; swingLowBuffer[i] = EMPTY_VALUE; } } }
Delete ";" after OnCalculate()
Wissam Hussein #: This should be return(rates_total)
That's one value that I never return.How to do your lookbacks correctly #9 — #14 & #19 (2016)
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