Conversion 3 Lines Strike TradingView
Forums › ProRealTime forum Français › Support ProBuilder › Conversion 3 Lines Strike TradingView
- This topic has 4 replies, 4 voices, and was last updated 1 month ago by RomainRR.
Viewing 5 posts - 1 through 5 (of 5 total)
-
-
04/08/2024 at 3:53 PM #231245
Bonjour Nicolas, Bonjour à tous,
Après une longue période d’absence pour des raisons personnelles, je reviens en force et motivé.
Je souhaiterais s’il est possible de pouvoir transposer ma stratégie que j’utilise sur TradingView vers PRT.
L’indicateur s’appelle 3 Lines Strike et voici le code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151// Inputs//// ### 3 Line Strike//showBear3LS = input.bool(title='Show Bearish 3 Line Strike', defval=true, group='3 Line Strike', tooltip="The Bearish 3 Line Strike (3LS-Bear) is a candlestick pattern comprised of 3 bullish (green) candles, " +"followed by a bearish engulfing candle (see 'Big A$$ Candles' below).\n\n" +"This pattern tends to be best used as a signal of the end of a retracement period as part of a trend continuation strategy.\n\n" +"Default: Checked")showBull3LS = input.bool(title='Show Bullish 3 Line Strike', defval=true, group='3 Line Strike', tooltip="The Bullish 3 Line Strike (3LS-Bull) is a candlestick pattern comprised of 3 bearish (red) candles, " +"followed by a bullish engulfing candle (see 'Big A$$ Candles' below).\n\n" +"This pattern tends to be best used as a signal of the end of a retracement period as part of a trend continuation strategy.\n\n" +"Default: Checked")showMemeChars = input.bool(title="Plot 3 Line Strike meme symbols", defval=false, group="3 Line Strike", tooltip="If disabled (default), standard shapes will be plotted instead, which can then be further customized on the 'Styles' tab of the indicator settings.\n\n" +"If enabled, meme icons hand-selected by Arty himself (🍆 and 🍑) will be plotted for 3LS signals instead of the more typical shapes.\n\n" +"Default: Unchecked")////### Engulfing Candles//showBearEngulfing= input.bool(title='Show Bearish Big A$$ Candles', defval=false, group='Big A$$ Candles', tooltip="Bearish 'Big A$$ Candles' are the same as Bearish Engulfing candles.")showBullEngulfing= input.bool(title='Show Bullish Big A$$ Candles', defval=false, group='Big A$$ Candles', tooltip="Bullish 'Big A$$ Candles' are the same as Bullish Engulfing candles.")////### Alerts//// This won't actually DO anything, just popping it to note the behavior of the "Any alert() function call" alert typevoid = input.bool(title="The new 'Any alert() function call' (dynamic) alerts will be based on what signals are enabled in the indicator settings.", defval=true, tooltip="This does nothing - it's only here to clarify alert functionality.")//// End Inputs ###// Function definitions...//// Derive candle "color". For simplicity, I originally wanted to make this a true/false and have any true doji candles (where open and close are exactly the same)// either inherit the previous value, or invalidate the setup (which was the original behavior), but that behavior wasn't working as expected. So for now, we're// going to do a hack and make this a numeric return instead, where...//// -1 -> Red/Bearish// 0 -> Doji// +1 -> Green/BUllish//getCandleColorIndex(barIndex) =>int ret = naif (close[barIndex] > open[barIndex])ret := 1else if (close[barIndex] < open[barIndex])ret := -1elseret := 0ret//// Check for engulfing candlesisEngulfing(checkBearish) =>// In an effort to try and make this a bit more consistent, we're going to calculate and compare the candle body sizes// to inform the engulfing or not decision, and only use the open vs close comparisons to identify the candle "color"ret = falsesizePrevCandle = close[1] - open[1] // negative numbers = red, positive numbers = green, 0 = dojisizeCurrentCandle = close - open // negative numbers = red, positive numbers = green, 0 = dojiisCurrentLagerThanPrevious = (math.abs(sizeCurrentCandle) > math.abs(sizePrevCandle)) ? true : false// We now have the core info to evaluate engulfing candlesswitch checkBearishtrue =>// Check for bearish engulfing (green candle followed by a larger red candle)isGreenToRed = ((getCandleColorIndex(0) < 0) and (getCandleColorIndex(1) > 0)) ? true : falseret := (isCurrentLagerThanPrevious and isGreenToRed) ? true : falsefalse =>// Check for bullish engulfing (red candle followed by a larger green candle)isRedToGreen = ((getCandleColorIndex(0) > 0) and (getCandleColorIndex(1) < 0)) ? true : falseret := (isCurrentLagerThanPrevious and isRedToGreen) ? true : false=> ret := false // This should be impossible to trigger...ret//// Helper functions that wraps the isEngulfing above...isBearishEngulfuing() =>ret = isEngulfing(true)ret//isBullishEngulfuing() =>ret = isEngulfing(false)ret//// Functions to check for 3 consecutive candles of one color, followed by an engulfing candle of the opposite color//// Bearish 3LS = 3 green candles immediately followed by a bearish engulfing candleis3LSBear() =>ret = falseis3LineSetup = ((getCandleColorIndex(1) > 0) and (getCandleColorIndex(2) > 0) and (getCandleColorIndex(3) > 0)) ? true : falseret := (is3LineSetup and isBearishEngulfuing()) ? true : falseret//// Bullish 3LS = 3 red candles immediately followed by a bullish engulfing candleis3LSBull() =>ret = falseis3LineSetup = ((getCandleColorIndex(1) < 0) and (getCandleColorIndex(2) < 0) and (getCandleColorIndex(3) < 0)) ? true : falseret := (is3LineSetup and isBullishEngulfuing()) ? true : falseret// ### 3 Line Strikeis3LSBearSig = is3LSBear()is3LSBullSig = is3LSBull()// Meme plots for the 3LS signalplotchar(showBull3LS and showMemeChars ? is3LSBullSig : na, char="🍆", color=color.rgb(0, 255, 0, 0), location=location.belowbar, size=size.tiny, text='3LS-Bull', title='3 Line Strike Up (Meme Icon)', editable=false)plotchar(showBear3LS and showMemeChars ? is3LSBearSig : na, char="🍑", color=color.rgb(255, 0, 0, 0), location=location.abovebar, size=size.tiny, text='3LS-Bear', title='3 Line Strike Down (Meme Icon)', editable=false)//// Standard plots for the 3LS signalplotshape(showBull3LS and not showMemeChars ? is3LSBullSig : na, style=shape.triangleup, color=color.rgb(0, 255, 0, 0), location=location.belowbar, size=size.small, text='3LS-Bull', title='3 Line Strike Up')plotshape(showBear3LS and not showMemeChars ? is3LSBearSig : na, style=shape.triangledown, color=color.rgb(255, 0, 0, 0), location=location.abovebar, size=size.small, text='3LS-Bear', title='3 Line Strike Down')//// # Alerts//// Old-style Alert Conditionsalertcondition(showBull3LS and is3LSBullSig, title='Bullish 3 Line Strike', message='{{exchange}}:{{ticker}} {{interval}} - Bullish 3 Line Strike')alertcondition(showBear3LS and is3LSBearSig, title='Bearish 3 Line Strike', message='{{exchange}}:{{ticker}} {{interval}} - Bearish 3 Line Strike')//// New-style alertsif (showBull3LS and is3LSBullSig)m = syminfo.tickerid + ' ' + timeframe.period + ' - Bullish 3 Line Strike'alert(message=str.tostring(m), freq=alert.freq_once_per_bar_close)if (showBear3LS and is3LSBearSig)m = syminfo.tickerid + ' ' + timeframe.period + ' - Bearish 3 Line Strike'alert(message=str.tostring(m), freq=alert.freq_once_per_bar_close)// End ###//### Engulfing Candles//If current bar open is less than equal to the previous bar close AND current bar open is less than previous bar open AND current bar close is greater than previous bar open THEN TrueisBullEngulfingSig = isBullishEngulfuing()//If current bar open is greater than equal to previous bar close AND current bar open is greater than previous bar open AND current bar close is less than previous bar open THEN TrueisBearEngulfingSig = isBearishEngulfuing()//bullishEngulfing/isBearEngulfingSig return a value of 1 or 0; if 1 then plot on chart, if 0 then don't plotplotshape(showBullEngulfing ? isBullEngulfingSig : na, style=shape.triangleup, location=location.belowbar, color=color.rgb(0, 255, 0, 0), size=size.tiny, title='Big A$$ Candle Up')plotshape(showBearEngulfing ? isBearEngulfingSig : na, style=shape.triangledown, location=location.abovebar, color=color.rgb(255, 0, 0, 0), size=size.tiny, title='Big A$$ Candle Down')// Alerts//// Old-style alert conditions...alertcondition(showBullEngulfing and isBullEngulfingSig, title='Bullish Engulfing', message='{{exchange}}:{{ticker}} {{interval}} - Bullish candle engulfing previous candle')alertcondition(showBearEngulfing and isBearEngulfingSig, title='Bearish Engulfing', message='{{exchange}}:{{ticker}} {{interval}} - Bearish candle engulfing previous candle')//// New-style alert() functions// New-style alertsif (showBullEngulfing and isBullEngulfingSig)m = syminfo.tickerid + ' ' + timeframe.period + ' - Bullish candle engulfing previous candle'alert(message=str.tostring(m), freq=alert.freq_once_per_bar_close)if (showBearEngulfing and isBearEngulfingSig)m = syminfo.tickerid + ' ' + timeframe.period + ' - Bearish candle engulfing previous candle'alert(message=str.tostring(m), freq=alert.freq_once_per_bar_close)// End ###Merci beaucoup par avance.
04/09/2024 at 8:53 AM #231275Bonjour, voici l'indicateur :
PRC_3 Coup de ligne1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162//---------------------------------------------------------------------////PRC_3 Line Strike//version = 0//09.04.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------------------------------////-----Inputs----------------------------------------------------------//showBullEngulfing=1showBearEngulfing=1//---------------------------------------------------------------------////-----Candle Color// -1 -> Red/Bearish// 0 -> Doji// +1 -> Green/BUllishif close>open thenret=1elsif close<open thenret=-1elseret=0endif//---------------------------------------------------------------------////-----Check for engulfing candles-------------------------------------//sizePrevCandle=close[1]-open[1]sizeCurrentCandle=close-openisCurrentLargerThanPrevious=abs(sizeCurrentCandle)>abs(sizePrevCandle)//---------------------------------------------------------------------////-----Check for bearish engulfing-------------------------------------////(green candle followed by a larger red candle)isGreenToRed=(ret<0 and ret[1]>0)checkBearish=isGreenToRed and isCurrentLargerThanPrevious//-----Check for bullish engulfing-------------------------------------////(red candle followed by a larger green candle)isRedToGreen=(ret>0 and ret[1]<0)checkBullish=isRedToGreen and isCurrentLargerThanPrevious//---------------------------------------------------------------------////-----Check for Bearish 3LS-------------------------------------------////3 green candles immediately followed by a bearish engulfing candleis3LineSetupGreen = ret[1]>0 and ret[2]>0 and ret[3]>0is3LSBear=is3LineSetupGreen and checkBearish//---------------------------------------------------------------------////-----Check for Bullish 3LS-------------------------------------------////3 red candles immediately followed by a bullish engulfing candleis3LineSetupRed=ret[1]<0 and ret[2]<0 and ret[3]<0is3LSBull=is3LineSetupRed and checkBullish//---------------------------------------------------------------------////-----Plots for the 3LS signal----------------------------------------//if is3LSBull thendrawtext("▲",barindex,low-0.25*tr)coloured("green")elsif is3LSBear thendrawtext("▼",barindex,high+0.25*tr)coloured("red")endif//---------------------------------------------------------------------////-----Plots Bullish/Bearish engulfing---------------------------------//if showBullEngulfing and checkBullish and not is3LSBull thendrawtext("⌃",barindex,low-0.25*tr)coloured("green")elsif showBearEngulfing and checkBearish and not is3LSBear thendrawtext("⌄",barindex,high+0.25*tr)coloured("red")endif//---------------------------------------------------------------------//return1 user thanked author for this post.
09/26/2024 at 2:55 PM #23807609/26/2024 at 3:28 PM #238080Publiez uniquement dans la langue du forum dans laquelle vous publiez. Par exemple, l’anglais uniquement dans les forums anglophones et le français uniquement dans les forums francophones.
Merci 🙂
09/30/2024 at 9:11 AM #238275 -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
Find exclusive trading pro-tools on
Similar topics: