Création / conversion code MA Bands
Forums › ProRealTime forum Français › Support ProBuilder › Création / conversion code MA Bands
- This topic has 3 replies, 2 voices, and was last updated 1 month ago by
Sofitech.
Viewing 4 posts - 1 through 4 (of 4 total)
-
-
01/11/2025 at 7:12 PM #242423
Bonjour à tous, Nicolas, Ivan.
J’ai essayé de faire une traduction de code mq4 vers probuilder en utilisant ChatGPT… ce n’est pas encore très opérationnel. J’aimerais convertir / créer le code PRT pour cet indicateur ci-dessous MA Bands…
En attendant que l’IA le permette, j’en appelle donc au forum.
—————————
Avertissement
—————————
Le fichier ‘MQL4\Indicators\MA_BBands_V4.2.mq4’ existe déjà !
Voulez-vous l’écraser ?
—————————
Oui Non
—————————01/11/2025 at 7:16 PM #24242401/14/2025 at 9:43 AM #242530123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384// PRC_MA BBands// Version: 0// 13.01.2025// Iván González @ www.prorealcode.com// Sharing ProRealTime knowledge//----------------------------------------------------------------//// Configurable Parameters//----------------------------------------------------------------//MAPeriod = 20 // Moving Average periodBBPeriod = 30 // Bollinger Bands periodStdDev = 1.0 // Standard deviation for Bollinger BandsMoveShift = 22 // SMA shiftOsMAFastPeriod = 5 // Fast EMAOsMASlowPeriod = 9 // Slow EMAOsMAPeriod = 4 // OsMA periodshortMAPeriod = 5 // Short SMA periodShowSignals = 1 // Show signals//----------------------------------------------------------------//// Simple Moving Averages (SMA) Calculation//----------------------------------------------------------------//MAUp = average[MAPeriod](high)MAUpshift = MAUp[MoveShift] // Value of the SMA high shifted by 22 periodsMADn = average[MAPeriod](low)MADnshift = MADn[MoveShift] // Value of the SMA low shifted by 22 periods//----------------------------------------------------------------//// Bollinger Bands Calculation with 7-Period Shift//----------------------------------------------------------------//bbUp = average[BBPeriod](high) + StdDev * std[BBPeriod](high) // Upper band using highsbbDn = average[BBPeriod](low) - StdDev * std[BBPeriod](low) // Lower band using lowsbbUpShift = bbUp[7] // Upper band shifted by 7 periodsbbDnShift = bbDn[7] // Lower band shifted by 7 periods//----------------------------------------------------------------//// OsMA Calculation//----------------------------------------------------------------//osmaNow = MACD[OsMAFastPeriod, OsMASlowPeriod, OsMAPeriod](close) // Current OsMA valueosmaPrev = osmaNow[1] // Previous OsMA value//----------------------------------------------------------------//// Upper Band Calculation//----------------------------------------------------------------//IF MAUpshift > 0 THENIF MAUpshift > bbUpShift THENupperBand = MAUpshift // Assign SMA to the bufferELSEupperBand = bbUpShift // Assign Bollinger upper band to the bufferENDIFELSEupperBand = bbUpShiftENDIF//----------------------------------------------------------------//// Lower Band Calculation//----------------------------------------------------------------//IF MADnshift > 0 THENIF MADnshift < bbDnShift THENlowerBand = MADnshift // Assign SMA low to the bufferELSElowerBand = bbDnShift // Assign Bollinger lower band to the bufferENDIFELSElowerBand = bbDnShiftENDIF//----------------------------------------------------------------//// Midline//----------------------------------------------------------------//midLine = (upperBand + lowerBand) / 2//----------------------------------------------------------------//// Short SMA Calculation//----------------------------------------------------------------//smaHighShort = average[shortMAPeriod](high)[1] // SMA of highs, shifted by one periodsmaLowShort = average[shortMAPeriod](low)[1] // SMA of lows, shifted by one period//----------------------------------------------------------------//// Sell Signals (Red Arrow)//----------------------------------------------------------------//IF ShowSignals AND smaHighShort > upperBand[1] AND osmaNow < 0 AND osmaPrev > 0 AND high > upperBand THENdrawarrowdown(barindex, high + 20 * pointsize) coloured("red") // Red arrow at the high priceENDIF//----------------------------------------------------------------//// Buy Signals (Green Arrow)//----------------------------------------------------------------//IF ShowSignals AND smaLowShort < lowerBand[1] AND osmaNow > 0 AND osmaPrev < 0 AND low < lowerBand THENdrawarrowup(barindex, low - 20 * pointsize) coloured("green") // Green arrow at the low priceENDIF//----------------------------------------------------------------//RETURN upperBand coloured("darkblue") style(line, 2), lowerBand coloured("darkred") style(line, 2), midLine coloured("fuchsia") style(dottedline, 2)01/15/2025 at 8:08 AM #242587 -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
Find exclusive trading pro-tools on
Similar topics: