-
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016) -
double previousLongMA=iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,i+2); if(Close[i+1]>High[i+2]){
Your lookback is two.
How to do your lookbacks correctly #9 — #14 & #19
Freezes because of array exceeded.
-
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016) - Your lookback is two.
How to do your lookbacks correctly #9 — #14 & #19
//--- int lookback=5; int counted = IndicatorCounted(); //+------------------------------------------------------------------+ for(int iBar=Bars-1-MathMax(lookback,counted);iBar>=0;--iBar){ Print("Hello"); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
I did it like in the examples and tried a Hello but its freezing still
Freezes because of array exceeded.
-
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016) - Your lookback is two.
How to do your lookbacks correctly #9 — #14 & #19
//+------------------------------------------------------------------+ //| 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[]) { //--- int lookback=5; int counted = IndicatorCounted(); //+------------------------------------------------------------------+ for(int iBar = MathMax(lookback, prev_calculated); iBar < Bars; ++iBar){ Print("Hello"); } return rates_total-1; // Recalculate current bar next tick. } //+------------------------------------------------------------------+
also freezing, I'm going crazy really...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The Algorithm of the Trailingstop only Long Example:
My Try:
My Question:
1.Do i have mistakes on the Algorithm of the Trailingstop?
2.Why Is my code alway freezing?