Conversion code RSI SWING de TV
Forums › ProRealTime forum Français › Support ProBuilder › Conversion code RSI SWING de TV
- This topic has 7 replies, 2 voices, and was last updated 7 months ago by Iván.
-
-
04/19/2024 at 4:28 PM #231709
Bonjour,
Serait-il possible de convertir le code ci dessous de TV a PRRT ?
Avec si possible la possibilité de faire afficher ou pas (au choix) les lignes.
En vous remerciant
1234567891011121314151617181920212223242526272829303132333435363738394041424344// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © BalintDavid// WHAT IT DOES AND HOW TO USE:// In the Input page you configure the RSI//// The indicator draws swings on the chart based on RSI extremes// Example: Lines are draws from OVERSOLD to OVERBOUGHT and vice-versa// If we keep geing in deeper OVERBOUGHT or OVERSOLD, the swinglines follow the price, till another cycle is complete// In the labels you see the swing's relation to the structure: If the swing high is higher then the previous, it becomes Higher High aka HH//@version=4study("RSI Swing Indicator", overlay=true, max_bars_back=1000)// RSI Settings for userrsiSource = input(title="RSI Source", type=input.source, defval=close)rsiLength = input(title="RSI Length", type=input.integer, defval=7)rsiOverbought = input(title="RSI Overbought", type=input.integer, defval=70, minval=51, maxval=100)rsiOvesold = input(title="RSI Oversold", type=input.integer, defval=30, minval=1, maxval=49)// RSI value based on inbuilt RSIrsiValue = rsi(rsiSource, rsiLength)// Get the current stateisOverbought = rsiValue >= rsiOverboughtisOversold = rsiValue <= rsiOvesold// State of the last extreme 0 for initialization, 1 = overbought, 2 = oversoldvar laststate = 0// Highest and Lowest prices since the last state changevar hh = lowvar ll = high// Labelsvar label labelll = navar label labelhh = na// Swing linesvar line line_up = navar line line_down = navar last_actual_label_hh_price = 0.0var last_actual_label_ll_price = 0.004/22/2024 at 10:27 AM #23180204/22/2024 at 11:08 AM #231806Bonjour
Effectivement le code ne c’est pas copié en totalité, je n’avais pas fait attention.
Sur la photo indication des haut et bas indiqué par cet indicateur ( avec possibilité de les reliers par une ligne (bleu) mais ligne pas essentielle.
Merci
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © BalintDavid// WHAT IT DOES AND HOW TO USE:// In the Input page you configure the RSI//// The indicator draws swings on the chart based on RSI extremes// Example: Lines are draws from OVERSOLD to OVERBOUGHT and vice-versa// If we keep geing in deeper OVERBOUGHT or OVERSOLD, the swinglines follow the price, till another cycle is complete// In the labels you see the swing's relation to the structure: If the swing high is higher then the previous, it becomes Higher High aka HH//@version=4study("RSI Swing Indicator", overlay=true, max_bars_back=1000)// RSI Settings for userrsiSource = input(title="RSI Source", type=input.source, defval=close)rsiLength = input(title="RSI Length", type=input.integer, defval=7)rsiOverbought = input(title="RSI Overbought", type=input.integer, defval=70, minval=51, maxval=100)rsiOvesold = input(title="RSI Oversold", type=input.integer, defval=30, minval=1, maxval=49)// RSI value based on inbuilt RSIrsiValue = rsi(rsiSource, rsiLength)// Get the current stateisOverbought = rsiValue >= rsiOverboughtisOversold = rsiValue <= rsiOvesold// State of the last extreme 0 for initialization, 1 = overbought, 2 = oversoldvar laststate = 0// Highest and Lowest prices since the last state changevar hh = lowvar ll = high// Labelsvar label labelll = navar label labelhh = na// Swing linesvar line line_up = navar line line_down = navar last_actual_label_hh_price = 0.0var last_actual_label_ll_price = 0.0// FUNCTIONSobLabelText() =>if(last_actual_label_hh_price < high)"HH"else"LH"//plot(last_actual_label_hh_price)osLabelText() =>if(last_actual_label_ll_price < low)"HL"else"LL"// Create oversold or overbought labelcreateOverBoughtLabel(isIt) =>if(isIt)label.new(x=bar_index, y=na ,yloc=yloc.abovebar, style=label.style_label_down, color=color.red, size=size.tiny, text=obLabelText())elselabel.new(x=bar_index, y=na ,yloc=yloc.belowbar, style=label.style_label_up, color=color.green, size=size.tiny, text=osLabelText())// Move the oversold swing and labelmoveOversoldLabel() =>label.set_x(labelll, bar_index)label.set_y(labelll, low)label.set_text(labelll, osLabelText())line.set_x1(line_down, bar_index)line.set_y1(line_down, low)moveOverBoughtLabel() =>label.set_x(labelhh, bar_index)label.set_y(labelhh, high)label.set_text(labelhh, obLabelText())line.set_x1(line_up, bar_index)line.set_y1(line_up, high)// We go from oversold straight to overbought NEW DRAWINGS CREATED HEREif(laststate == 2 and isOverbought)hh := highlabelhh := createOverBoughtLabel(true)last_actual_label_ll_price := label.get_y(labelll)labelll_ts = label.get_x(labelll)labelll_price = label.get_y(labelll)line_up := line.new(x1=bar_index, y1=high, x2=labelll_ts, y2=labelll_price, width=1)// We go from overbought straight to oversold NEW DRAWINGS CREATED HEREif(laststate == 1 and isOversold)ll := lowlabelll := createOverBoughtLabel(false)last_actual_label_hh_price := label.get_y(labelhh)labelhh_ts = label.get_x(labelhh)labelhh_price = label.get_y(labelhh)line_down := line.new(x1=bar_index, y1=high, x2=labelhh_ts, y2=labelhh_price, width=1)// If we are overboughtif(isOverbought)if(high >= hh)hh := highmoveOverBoughtLabel()laststate := 1// If we are oversoldif(isOversold)if(low <= ll)ll := lowmoveOversoldLabel()laststate := 2// If last state was overbought and we are overboughtif(laststate == 1 and isOverbought)if(hh <= high)hh := highmoveOverBoughtLabel()//If we are oversold and the last state was oversold, move the drawings to the lowest priceif(laststate == 2 and isOversold)if(low <= ll)ll := lowmoveOversoldLabel()// If last state was overboughtif(laststate == 1)if(hh <= high)hh := highmoveOverBoughtLabel()// If last stare was oversoldif(laststate == 2)if(ll >= low)ll := lowmoveOversoldLabel()04/23/2024 at 9:17 AM #231826Bonjour
Voici le code traduit :
https://www.prorealcode.com/prorealtime-indicators/rsi-swing-indicator/Indicateur de swing PRC_RSI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485//--------------------------------------------------------------////PRC_RSI Swing Indicator//version = 0//23.04.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------------------------////----Inputs----------------------------------------------------//rsisource=customclosersiLength=7rsioverbought=70rsioversold=30//--------------------------------------------------------------////-----RSI value------------------------------------------------//rsivalue=rsi[rsilength](rsiSource)//-----Current State--------------------------------------------//isOverbought = rsiValue >= rsiOverboughtisOversold = rsiValue <= rsioversold//--------------------------------------------------------------////-----High and low channel-------------------------------------////---Low: calculated when is not overboughtif isOverbought thennotob=0elsenotob=notob+1pl=lowest[notob](low)plx=barindex-barssince(pl=low)endif//---High: calculated when is not oversoldif isOversold thennotos=0elsenotos=notos+1ph=highest[notos](high)phx=barindex - barssince(ph=high)endif//--------------------------------------------------------------////-----Pivot Points (High&Low)----------------------------------////---Check after exit oversold stateif isoversold[1] and not isoversold thenprevlastosx=lastosx//keep the previous pivot barindexlastosx=plx//set the new pivot barindex//---Draw only if is the last highif lastosx>lastobx and prevlastosx < lastobx thenlasty1=y1x1=phx[1]y1=ph[1]drawpoint(x1,y1,2)coloured("red")drawsegment(x1,y1,x2,y2)coloured("blue")style(dottedline)if lasty1 > y1 thendrawtext("LH",x1,y1+0.5*tr)coloured("red")elsedrawtext("HH",x1,y1+0.5*tr)coloured("red")endifendifendif//---Check after exit overbought stateif isOverbought[1] and not isOverbought thenprevlastobx=lastobx//keep the previous pivot barindexlastobx=phx//set the new pivot barindex//---Draw only if is the last lowif lastobx>lastosx and prevlastobx < lastosx thenlasty2=y2x2=plx[1]y2=pl[1]drawpoint(x2,y2,2)coloured("green")drawsegment(x2,y2,x1,y1)coloured("blue")style(dottedline)if lasty2 > y2 thendrawtext("LL",x2,y2-0.5*tr)coloured("green")elsedrawtext("HL",x2,y2-0.5*tr)coloured("green")endifendifendif//--------------------------------------------------------------////-----Draw the last segment------------------------------------//if islastbarupdate thenif x1 > x2 thendrawsegment(x1,y1,plx,pl)coloured("blue")style(dottedline)elsedrawsegment(x2,y2,phx,ph)coloured("blue")style(dottedline)endifendif//--------------------------------------------------------------//return04/23/2024 at 10:34 AM #231837Bonjour
Merci pour le retour rapide.
J’ai installé l’indicateur sur PRT Temps réel ( et aussi fin de journée), sur plusieurs sous jacents contrairement a TV le dernier low ou Hi ne s’affiche pas.
pour quelle raison ? (voir photo jointe)
Merci
04/23/2024 at 10:41 AM #231840Bonjour Il n’est pas affiché car il n’a pas encore été réellement généré. C’est pour cette raison qu’il n’est pas étiqueté. Dans le code TV, ils l’ont mis à titre provisoire, mais j’ai choisi de ne pas le mettre car c’est trompeur. Comme vous pouvez le voir sur le graphique, la ligne bleue en pointillés le marque, mais elle ne le marque pas.
Si vous souhaitez l’ajouter, vous pouvez le faire en suivant la même logique que dans les lignes de code où la balise est placée.
04/23/2024 at 10:47 AM #23184304/23/2024 at 2:16 PM #231852 -
AuthorPosts
Find exclusive trading pro-tools on