Conversion Steven Primo Strategie de Tradingview
Forums › ProRealTime forum Français › Support ProBuilder › Conversion Steven Primo Strategie de Tradingview
- This topic has 5 replies, 2 voices, and was last updated 2 years ago by
Alex72.
-
-
08/21/2022 at 3:53 PM #199341
C’est la Stratégie de Steven primo qui consiste en:
1) Setup des Bolligner Bands avec deviation de 0.382
2) Attendre une clôture de la 5ème bougie au dessus des haut des Bollinger bands.
3) Repérer le dernier Swing Haut qui s’est formé dans ces 5 dernières bougies ou attendre la formation d’un Swing Haut sans que le prix ne clôture sous le Haut du BB.
4) Si on n’a pas eu de Swing Haut et qu le prix clôture sous le haut des BB, le processus se repete et donc on attend à nouveau la formation de 5 bougies qui clôturent au dessus du haut des BB et un swing High.
5) Entrée automatique si on on casse le Swing High.
6) Placer un Stop sous le dernier Swing Low et le Take profit à la même distance que le Stop.j’ai pu avec l’aide de JC_Bywan, Nicolas, robertogozzi faire une petite partie du code que je vais partager dans les réponses mais il reste encore du travail à faire.
Je vous remercie pour votre aide.08/21/2022 at 3:54 PM #199343123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © EduardoMattje//@version=5strategy("Steven Primo Bollinger Band", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true, max_labels_count=500)// Constantsvar TRANSP = 5var LONG = strategy.direction.longvar SHORT = strategy.direction.shortvar ALL = strategy.direction.allvar S_BOLLINGER = "Bollinger settings"var S_SETUP = "Setup settings"// Inputssrc = math.log(input.source(close, "Price source", group=S_BOLLINGER))var bollingerLength = input.int(20, "Bollinger length", minval=3, group=S_BOLLINGER, inline=S_BOLLINGER)var mult = input.float(0.382, "Standard deviation", minval=0.0, step=0.1, group=S_BOLLINGER, inline=S_BOLLINGER)var orderDirection = input.string(LONG, "Order direction", options=[LONG, SHORT, ALL], group=S_SETUP)var useTrailingStop = input.bool(false, "Use trailing stop", group=S_SETUP)var consecutiveCloses = input.int(5, "Consecutive closes for the setup", minval=1, group=S_SETUP, inline=S_SETUP)var extension = input.int(100, "Extension (%)", minval=100, group=S_SETUP, inline=S_SETUP) / 100.0// Getting the BB[middle, upper, lower] = ta.bb(src, bollingerLength, mult)middle := math.exp(middle)upper := math.exp(upper)lower := math.exp(lower)// Plotting the BBvar colorAtTheLimits = color.new(color.yellow, TRANSP)var colorAtTheMiddle = color.new(color.blue, TRANSP)plot(middle, "Middle band", colorAtTheMiddle, display=display.none)plot(upper, "Upper band", colorAtTheLimits)plot(lower, "Lower band", colorAtTheLimits)// MA setup// BB setuplongComparison() => close >= uppershortComparison() => close <= lowervar countLong = 0var countShort = 0incCount(count, comparison) =>if comparisonif count == 0 and comparison[1]0elsecount + 1else0countLong := incCount(countLong, longComparison())countShort := incCount(countShort, shortComparison())// Pivot setuppivotHigh = ta.pivothigh(1, 1)pivotLow = ta.pivotlow(1, 1)pivotInRange(pivot, count) => ta.barssince(pivot) < countpvHighInRange = pivotInRange(pivotHigh, countLong)pvLowInRange = pivotInRange(pivotLow, countShort)// Entry priceepLong = fixnan(pivotHigh) + syminfo.mintickepShort = fixnan(pivotLow) - syminfo.mintick// Stop pricegetRange(currentPrice, pivot, cond, tickMod) =>if condcurrentPriceelsefixnan(pivot) + syminfo.mintick * tickModvar stopLong = 0.0var stopShort = 0.0stopLong := epShortstopShort := epLong// Target pricegetTarget(stopPrice, entryPrice) =>totalTicks = (entryPrice - stopPrice) * extensionentryPrice + totalTicksvar targetLong = 0.0var targetShort = 0.0targetLong := getTarget(stopLong, epLong)targetShort := getTarget(stopShort, epShort)// Entry conditioncanBuy = countLong >= consecutiveCloses and pvHighInRange and high < epLongcanSell = countShort >= consecutiveCloses and pvLowInRange and low > epShort// Entry ordersinMarket = strategy.opentrades != 0var plotTarget = 0.0var plotStop = 0.0strategy.risk.allow_entry_in(orderDirection)if not inMarketif canBuyplotTarget := targetLongplotStop := stopLongstrategy.entry("long", strategy.long, stop=epLong, comment="Entry long")else if canSellplotTarget := targetShortplotStop := stopShortstrategy.entry("short", strategy.short, stop=epShort, comment="Entry short")elsestrategy.cancel("long")strategy.cancel("short")// Exit ordersstrategy.exit("long", "long", stop=stopLong, limit=targetLong, comment="Exit long")strategy.exit("short", "short", stop=stopShort, limit=targetShort, comment="Exit short")elsecountLong := 0countShort := 0// Trailing stopif useTrailingStop and inMarketif strategy.position_entry_name == "long"strategy.exit("long", "long", stop=stopLong, limit=plotTarget, comment="Exit long", when=stopLong > plotStop)plotStop := stopLongelsestrategy.exit("short", "short", stop=stopShort, limit=plotTarget, comment="Exit short", when=stopShort < plotStop)plotStop := stopShort// Plot exitplotCond(price) => inMarket ? price : inMarket[1] ? price[1] : naplot(plotCond(plotStop), "Stop loss", color.red, style=plot.style_linebr)plot(plotCond(plotTarget), "Target", color.teal, style=plot.style_linebr)08/21/2022 at 4:23 PM #199348Avec l’aide de Nicolas j’ai pu avoir ce code qui me trace un segment une fois la condition de 5 bougies qui clôturent au dessus des BB mais le segment est tracé au niveau du haut des 5 dernières bougies mais ce que je voudrait avoir c’est le dernier Swing High après la formation de ces 5 bougies ou meême plus comme illustré dans la photo.
1234567891011121314151617181920212223242526ONCE x = 0ONCE y = 0ONCE Count = 0ONCE N = 5Count = Count - 1indicator3 = Average[20](close)+0.382*std[20](close)Above = summation[N](close > indicator3) = NPivot = highest[N](high)IF Above AND (Count <= 0) THENx = BarIndex-N+1y = PivotCount = 5Drawsegment(x-1,y,BarIndex,y) coloured(0,0,255,255)ENDIFindicator4 = Average[20](close)-0.382*std[20](close)Below = summation[N](close < indicator4) = NPivotLow = lowest[N](low)IF Below AND (Count <= 0) THENx = BarIndex-N+1y = PivotLowCount = 5Drawsegment(x,y,BarIndex,y) coloured(255,0,0,255)ENDIFRETURN08/21/2022 at 4:44 PM #199351Condition 1 :Tracer une flèche si on a 5 clôtures au dessus ou sous BB avec ce code.
Condition 2: Repérer le dernier Swing High ou Low
Condition 3: Si on a condition 1 et condition 2, entrer Long ou short si on casse respectivement le Swing High ou Low et placer les Stop respectivement sous le dernier Swing Low ou High et la Target à la même distance du Stop.Voilà pour la condition 1
1234567891011121314151617181920212223242526272829303132333435363738atr=averagetruerange[14]// Conditions pour Close > Bollinger UPindicator3 = Average[20](close)+0.382*std[20](close)c7 = (close > indicator3)// Conditions pour Close < Bollinger Downindicator4 = Average[20](close)-0.382*std[20](close)c8 = (close < indicator4)// Conditions pour 5 Cloture au dessus de Bollinger Upc9=SUMMATION[5](c7)=5//condition pour que la flèche ne surgisse que si le prix est au dessus de SMA20 et SMA50 et SMA20> SMA50 ca donne moins de signaux mais plus interessants// Inverse pour Bearishsma50 = Average[50](close)sma20 = Average[20](close)//Bullish = Close > sma50 and close > sma20 and sma20>sma50//Bearish = Close < sma50 and close < sma20 and sma20<sma50// Fleche Haut si min 5 Close > Bollinger UP//Condition = c9 and bullish and lastsig = 0if c9 and lastsig=0 thendrawarrowup(barindex,low-atr) coloured(0,255,255)lastsig=1endif//Le processus se met à zéro si on cloture à nouveau sous Boll Upif close<indicator3 thenlastsig=0endif// Conditions pour 5 Cloture en dessous de Bollinger downc10=SUMMATION[5](c8)=5// Fleche Bas si min 5 Close < Bollinger Downif c10 and lastsig2=0 thendrawarrowdown(barindex,high+atr) coloured(255,102,102)lastsig2=1endif//Le processus se met à zéro si on cloture à nouveau au dessus de Boll Downif close>indicator4 thenlastsig2=0endifreturn08/22/2022 at 3:39 PM #199400Je suppose que c’est lié à ton indicateur: https://www.prorealcode.com/topic/eviter-les-repetitions/
Donc tout est ok désormais ? 🙂
08/22/2022 at 4:06 PM #199410Oui c’est sur mais ca c’est tout le code et je suis entrain d’essayer de le faire petit à petit.
je pense qu’il ya des personnes comme vous bien sur qui maitrisent bien votre codage, moi je ne suis q’u petit débutant et je pensais aider avec le peu que j’ai fait mais il reste encoe du chemin à faire.
Merci -
AuthorPosts
Find exclusive trading pro-tools on