Hello Friends!
I tried to convert an indicator from MQL4 to MQL5. the indicator named: Swing Cloud and I don't know what is wrong with MQL5 code.
In uptrend the cloud should be below the price and in downtrend the cloud should be above the price.
Here is on MT4 it print the cloud in the correct position.
But the cloud printed on MT5 is not in the correct position.
here is the code
Traders and coders are working for free:
- if it is interesting for them personally, or
- if it is interesting for many members on this forum.
Freelance section of the forum should be used in most of the cases.
- 2026.02.10
- www.mql5.com
1. Count up.
2. Make atrValues[] a buffer and only copy what is necessary.
// Calculate start position int start=(rates_total==prev_calculated)?rates_total-1:prev_calculated; if(prev_calculated == 0) { // First calculation // Initialize buffers with EMPTY_VALUE ArrayInitialize(buff_Stop, EMPTY_VALUE); ArrayInitialize(buff_Swing, EMPTY_VALUE); ArrayInitialize(buff_CloudUp, EMPTY_VALUE); ArrayInitialize(buff_CloudDown, EMPTY_VALUE); ArrayInitialize(buff_LowerBand, EMPTY_VALUE); ArrayInitialize(buff_UpperBand, EMPTY_VALUE); ArrayInitialize(buff_Trend, EMPTY_VALUE); // Initialize trend from the first bar buff_Trend[start++] = 0.0; } // Copy ATR values //double atrValues[]; int toCopy=(rates_total==prev_calculated)?1:rates_total-prev_calculated; if(CopyBuffer(atrHandle, 0, 0, toCopy, atr_Values) <= 0) { Print("Failed to copy ATR values"); return 0; } // Main calculation loop for(int i = start; i < rates_total; i++) { double atr = atr_Values[i]; // Skip if ATR is not valid if(atr <= 0 || atr == EMPTY_VALUE) { buff_Stop[i] = buff_Stop[i-1]; buff_Swing[i] = buff_Swing[i-1];
Hello Friends!
I tried to convert an indicator from MQL4 to MQL5. the indicator named: Swing Cloud and I don't know what is wrong with MQL5 code.
In uptrend the cloud should be below the price and in downtrend the cloud should be above the price.
Here is on MT4 it print the cloud in the correct position.
But the cloud printed on MT5 is not in the correct position.
here is the code
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Friends!
I tried to convert an indicator from MQL4 to MQL5. the indicator named: Swing Cloud and I don't know what is wrong with MQL5 code.
In uptrend the cloud should be below the price and in downtrend the cloud should be above the price.
Here is on MT4 it print the cloud in the correct position.
But the cloud printed on MT5 is not in the correct position.
here is the code