un indicateur, deux graphiques différents
Forums › ProRealTime forum Français › Support ProBuilder › un indicateur, deux graphiques différents
- This topic has 2 replies, 2 voices, and was last updated 1 day ago by
larouedegann.
-
-
06/19/2025 at 8:32 PM #248413
Bonjour,
Voici ci-dessous l’indicateur Moving avg trend sniper que j’utilise pour trader.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899//-----------------------------------------////PRC_Moving Avg Trend Sniper//version = 0//19.05.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------//// === PARAMETERS ===//-----------------------------------------////length = 30 // main smoothing lengthwildersPeriod = length * 4 - 1atrPeriod = length//atrMult = 0.5 // multiplier for upper/lower ATR band//-----------------------------------------//// === CUSTOM EMA FUNCTION ===//-----------------------------------------//ONCE atrema = 0ONCE count = 0IF barindex <= 1 THENatrema = 0count = 0ELSEcount = count + 1atrema = (1 - 2 / (count + 1)) * atrema + 2 / (count + 1) * trENDIF//-----------------------------------------//// === TRA() FUNCTION ===//-----------------------------------------//atrLocal = atremaslope = (close - close[10]) / (atrLocal * 10)angle = ATAN(slope)IF angle > 0 THENsource = average[2](high)ELSEsource = average[2](low)ENDIF//-----------------------------------------//// === CHEBYSHEV-LIKE ADAPTIVE SMOOTHING ===//-----------------------------------------//// Applies smoothing only when barindex is sufficientIF barindex <= length THENsmooth = closeELSEhighChange = (HIGHEST[length](high) - HIGHEST[length+1](high)) <> 0lowChange = (LOWEST[length+1](low) - LOWEST[length](low)) <> 0boolImpulse = highChange OR lowChangetimeConstant = POW(AVERAGE[length](boolImpulse), 2)smooth = smooth + timeConstant * (source - smooth)ENDIF//-----------------------------------------//// === MODIFIED ATR CALCULATION ===//-----------------------------------------//atr = ABS(smooth[1] - smooth)maAtr = average[wildersPeriod,1](atr)deltaATR = average[wildersPeriod](maAtr) * length * 0.4//-----------------------------------------//// === MATS CALCULATION ===//-----------------------------------------//// Adaptive moving average trend filter with direction-sensitive filteringONCE mats = smoothIF smooth > mats[1] THENIF smooth - deltaATR < mats[1] THENmats = mats[1]ELSEmats = smooth - deltaATRENDIFELSEIF smooth + deltaATR > mats[1] THENmats = mats[1]ELSEmats = smooth + deltaATRENDIFENDIF//-----------------------------------------//// === ATR-BASED ENVELOPE BANDS ===//-----------------------------------------//atr10 = atrema / 2maxBand = mats + atr10 * atrMultminBand = mats - atr10 * atrMult//-----------------------------------------//// === DYNAMIC COLORING BASED ON TREND DIRECTION ===//-----------------------------------------//IF AVERAGE[2](close) > mats THENr = 0g = 0b = 255ELSEr = 255g = 0b = 255ENDIF// Shaded background between bandscolorbetween(maxBand, minBand, r, g, b, 30)//-----------------------------------------//RETURN mats COLOURED(r, g, b) STYLE(line, 3)sur le premier graphique qui est celui du réel car j’ai pris des positions dessus on a des zones bien définis, dont 130.76 sur lequel
j’ai pris un achat. Quel fut pas ma surprise le soir en voyant ces zones complètements différentes de la journée.
et ce que cet indicateur ne redessinerait-il pas ?
06/20/2025 at 9:35 AM #248424Bonjour.
Le comportement que vous observez ne correspond pas à un “repeint en temps réel” classique, mais plutôt au fait que l’indicateur part d’une valeur initiale de avg qui dépend de la première donnée chargée sur le graphique. Comme à la ligne onze avg = src, la valeur de avg est initialisée avec le close de la première bougie chargée ; si aujourd’hui vous commencez à partir du 1er juin et que demain seules les données à partir du 2 juin sont chargées, le point de départ sera différent.Cela implique que le premier croisement significatif de src – avg > atr se produira à un moment différent (puisque le avg initial est différent), et comme l’algorithme est séquentiel (type “cascade”), les niveaux dérivés (prR1, prR2, etc.) sont générés à des moments différents et avec des valeurs également différentes.
C’est un effet inévitable lorsque l’on utilise une logique séquentielle qui part d’un état initial variable. Si vous souhaitez l’éviter, vous devriez fixer un point d’ancrage constant (par exemple, en forçant la valeur initiale de avg à une valeur fixe par jour ou par session) ou bien contrôler à quel moment avg peut être mis à jour.
Pour éviter ce comportement, j’ai introduit une condition qui définit un point de départ fixe afin que le calcul de avg et des niveaux associés ne soit effectué qu’à partir d’une date précise (startDate). Avant cette date, les variables restent undefined pour empêcher une initialisation incorrecte.12345678910startDate = 20250606IF opendate <= startDate THENavg = undefinedprR2 = undefinedprR1 = undefinedprS1 = undefinedprS2 = undefinedELSE// IndicatorENDIF06/20/2025 at 7:20 PM #248459 -
AuthorPosts
Find exclusive trading pro-tools on