Conversion indicateur TradingView
Forums › ProRealTime forum Français › Support ProBuilder › Conversion indicateur TradingView
- This topic has 7 replies, 2 voices, and was last updated 6 months ago by Iván.
-
-
05/29/2024 at 1:45 PM #233230
Bonjour,
Il y a quelque temps j’avais demandé un équivalent du code tradingview mais je ne peux plus accéder à la page. Par ailleurs, le code que l’on m’a proposé ne correspond pas tout à fait (ou peut-être les modifications que j’en ai faites).
La page de l’indicateur (mentfx Structure) : mentfx Structure
L’explication de l’auteur du code tradingview :
The indicator is designed to identify and track swing highs and lows in a given market on any timeframe, and display them on the chart as solid lines (the lines you see are denoting highs and lows). The lines are customizable in terms of color and width, as determined by the user input.
The rules for creating a new high or low are based on whether the current range is considered Bullish (most recent break being to the topside) or whether the current range is considered Bearish (most recent breaking being to the downside). If the range is Bullish, the code will allow for wicks below the low without updating the low, and will only change in the case that a candle’s body (open or close) finds itself under that given low. If the range is Bearish, the code will allow for wicks above the high without updating the high, and will only change in the case that a candle’s body (open or close) finds itself above that given high.
When a range is assigned as being bullish, it will continue updating the high until a swing high is created (denoting that as the high of the range) and will not update or change until a candle’s body, open’s or close’s above it – which will reupdate the high and update the low. The low will be updated based on the last time price had a candle (open or closure) below a previous candles low, and then will find the lowest low after the rule was met to assign a low (the idea here is to locate the last major “sell before buy” and showcase that range. And this will occur vice versa, where: when a range is assigned as bearish, it will continue updating the low until a swing low is created (denoting that as the low of the range) and will not update or change until a candle’s body, open’s or close’s below it – which will reupdate the low and update the high. The high will be updated based on the last time price had a candle (open or closure) above a previous candles high, and then will find the highest high after the rule was met to assign a high (once again, the idea being to locate the last major “buy before sell” and showcase price as existing in that range.
A swing high is considered as a high that has a lower high to its left and to its right. And a swing low is considered as a low that has a higher low to its left and to its right. These swings are used to determine the final high or low of a Bullish or Bearish range (respectively).
Additionally, the script includes a function that updates the lines on the chart as new market data prints (using the logic described above).
The indicator uses a specific method (mentioned above) based on the idea of “sells before buys” (for Bullish Ranges) and “buys before sells” (for Bearish Ranges) that isnt found in other indicator. The channels shown on the screen represent prior highs and lows, as well as current updated highs and lows based on this. The reason for using this way to track Structure is that we are assuming large money is selling before purchasing heavily, and buying before selling heavily, and these ranges attempt to showcase the structural delivery of price on any timeframe in reference to this theory – theory being that if we are in a bullish range, we are likely to sustain some sort of bullish move until the next high or for a while, or from the last “sell before buy” – and vice versa. As well as being able to merge the “context” or “story” of multiple timeframes in reference to this indicator as confluence for bullish or bearish continuations. Follow’s the school of thought that comes with trend following.
Et le code PRT qu’il me reste :
Structure12345678910111213141516171819202122232425262728293031323334353637383940once bandebas= lowonce bandehaut=highonce majbasom=0once majhautok=0if low<low[1] thenprechaut= highest[barindex-barrefbas+1](high)endifif high>high[1] thenprecbas= lowest[barindex-barrefhaut+1](low)endifif close>bandehaut thenbandehaut=highbarrefhaut=barindexopenrefbas= Lowif majbasok thenbandebas=precbasendifmajbasok=0endifif close<bandebas thenbandebas=lowbarrefbas=barindexopenrefhaut= highif majhautok thenbandehaut=prechautendifmajhautok=0endifif close<openrefbas thenmajbasok=1endifif close>openrefhaut thenmajhautok=1endifreturn bandehaut as "bande haute 1m", bandebas as "bande basse 1m"L’image ci-dessous montre le comportement que j’obtiens en blanc et celui que j’aimerais avoir en rose.
Si une bonne ame pouvait m’aider ça serait merveilleux.
Bonne journée.
05/30/2024 at 11:39 AM #233282J’ai essayé de traduire l’explication du code TradingView en pseudo-langage informatique et j’obtiens ça :
Haussier = Prix > BOS
Baissier = Prix < BOSswingHaut = PlusHaut [2] < PlusHaut [1] and PlusHaut < PlusHaut [1]
swingBas = Plusbas [2] > Plusbas [1] and Plusbas > Plusbas [1]If Range = Haussier then
If close < plusbas then
Maj plusbas
BOS
EndifIf swingHaut = True Then
If close > swingHaut then
Plusbas =Lowest ( last low<Low[1])
PlusHaut = Highest (last haut<Haut[1])
Maj plusbas
Maj PlusHaut
endif
Else
PlusHaut= High
Endif
EndifIf Range = Baissier then
If close > plushaut then
Maj plushaut
BOS
Endif
If swingBas = True Then
If close < swingBas then
Plusbas =Lowest ( last low<Low[1])
PlusHaut = Highest (last haut<Haut[1])
Maj plusbas
Maj PlusHaut
Else
PlusBas = Low
Endif
Endif05/30/2024 at 11:47 AM #23328405/30/2024 at 1:55 PM #23329206/05/2024 at 2:32 PM #233540Hola, il a créé ce code qui vous intéressera :
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667//-------------------------------------------------------------------//prd = 5src1 = lowsrc2 = high//pivots lowif src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then$ply[z+1] = src1[prd]$plx[z+1] = barindex[prd]z = z + 1endif//pivots highif src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then$phy[t+1]=src2[prd]$phx[t+1]=barindex[prd]t=t+1endif//-------------------------------------------------------------------//if barindex<prd*20 thenlmax=highlmin=lowbearish=0bullish=0else//--------------------------------------------------------------//if open > lmax[1] or close > lmax[1] and bearish thenbullish=1bearish=0lmax=max(high,lmax[1])lmin=max($ply[z],lmin[1])elsif bullish thenlmax=max(high,lmax[1])if open > lmax[1] or close > lmax[1] thenlmin=max(lmin[1],$ply[z])elsif open<lmin[1] or close<lmin[1] thenlmin=lowbearish=1bullish=0elselmin=lmin[1]endif//--------------------------------------------------------------//elsif open < lmin[1] or close < lmin[1] and bullish thenlmin=min(low,lmin[1])lmax=min($phy[t],lmax[1])bearish=1bullish=0elsif bearish thenlmin=min(low,lmin[1])if open > lmax[1] or close > lmax[1] thenlmax=max(high,lmax[1])bearish=0bullish=1elsif open < lmin[1] or close < lmin[1] thenlmax=min(lmax[1],$phy[t])elselmax=lmax[1]endifendifendif//--------------------------------------------------------------//if bullish thenbackgroundcolor("green",50)elsif bearish thenbackgroundcolor("red",50)endif//--------------------------------------------------------------//return lmax as "Lmax" coloured("blue"), lmin as "lmin" coloured("red")//,$phy[t]style(dottedline),$ply[z]style(dottedline)1 user thanked author for this post.
06/05/2024 at 9:47 PM #23356706/06/2024 at 6:09 PM #233596Bonjour Iván,
Le code ne se comporte pas comme attendu, les niveaux mis à jour lors d’une cassure de bande devraient correspondre :
En cas de cassure à la baisse d’un range haussier : Au dernier plus haut comportant un plus haut[2] plus bas, un plus haut[1] plus haut et un plus haut[0] plus bas (en gros sur trois bougies en prenant les max, une figure tete épaule)
Voici en blanc ce que le code devrait faire.
Cordialement.
06/10/2024 at 3:32 PM #233688Si vous modifiez la variable prd en
prd=1
alors vous obtenez des valeurs plus similaires à celles que vous indiquez. Quoi qu'il en soit, comme je l'ai dit l'autre jour. C'est une approximation (je n'ai pas le code). Salutations1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on