ProRealCode - Trading & Coding with ProRealTime™
a
Aviez-vous l’intention d’écrire quelque chose ou s’agissait-il d’une erreur ?
Deux secondes please. Snail
TurtlesoupSNAIL
The code
// Turtle Soup Strategy - ProOrder
DEFPARAM CumulateOrders = False
// --- Parameters ---
Lookback = 20 // 20-period range
MinDist = 4 // Previous extreme must be at least 4 bars ago
Offset = 5 * pipsize // Entry buffer above/below extreme
// --- Define 20-period high and low (excluding current bar) ---
Low20 = Lowest[Lookback](low)[1]
High20 = Highest[Lookback](high)[1]
// --- Identify the previous extreme's position ---
BarOfLow = LowestBars[Lookback](low)[1]
BarOfHigh = HighestBars[Lookback](high)[1]
// --- Conditions ---
// Bullish: New low today, but previous 20-period low was > 4 bars ago
BullishSetup = (low < Low20) AND (BarOfLow >= MinDist)
// Bearish: New high today, but previous 20-period high was > 4 bars ago
BearishSetup = (high > High20) AND (BarOfHigh >= MinDist)
// --- Entry Logic (Fade the breakout) ---
IF BullishSetup THEN
BUY 1 CONTRACT AT Low20 + Offset STOP
ENDIF
IF BearishSetup THEN
SELLSHORT 1 CONTRACT AT High20 - Offset STOP
ENDIF
// --- Simple Exit (Exit on target or after X bars) ---
SET TARGET pPROFIT 50
SET STOP pLOSS 25
Voici également le document de présélection
// Turtle Soup Screener
Lookback = 20
MinDist = 4
// Get 20-period extremes from previous bars
Low20 = Lowest[Lookback](low)[1]
High20 = Highest[Lookback](high)[1]
// Find when those extremes occurred
BarOfLow = LowestBars[Lookback](low)[1]
BarOfHigh = HighestBars[Lookback](high)[1]
// Detect the false breakout (price currently below/above but reversing)
BullishSoup = (low < Low20) AND (close > Low20) AND (BarOfLow >= MinDist)
BearishSoup = (high > High20) AND (close < High20) AND (BarOfHigh >= MinDist)
// Sorting criteria (1 for Buy, -1 for Sell)
IF BullishSoup THEN
Signal = 1
ELSIF BearishSoup THEN
Signal = -1
ELSE
Signal = 0
ENDIF
SCREENER[Signal <> 0] (Signal AS "1=Buy -1=Sell")
Codes PRT prêts à compiler — Option C trailing stop intégrée
Vert = R/R ≥ 2.3 | Jaune = R/R ≥ 1.9 | Rouge = R/R < 1.9
#
Profil
Donchian
RSI L/H
Stop
Target
Trail
R/R
1
Scalp agressif
20
32 / 68
0.8
1.5
0.4
1.88
2
Équilibré court
25
30 / 70
1.0
2.0
0.5
2.00
3
Référence v1.0
30
32 / 68
1.2
2.0
0.6
1.67
4
Filtres stricts
30
28 / 72
1.2
2.5
0.6
2.08
5
Momentum moyen
35
30 / 70
1.4
2.5
0.6
1.79
6
Target étendu
35
32 / 68
1.2
3.0
0.7
2.50
7
Swing court
40
30 / 70
1.4
2.8
0.7
2.00
8
Trend-following
40
28 / 72
1.6
3.0
0.8
1.88
9
Intermédiaire
45
30 / 70
1.4
2.5
0.7
1.79
10
Conservateur
50
28 / 72
1.6
3.0
0.8
1.88
Donchian : 20 | RSI : 32/68 | Stop : 0.8× ATR | Target : 1.5× ATR | Trailing : 0.4× ATR | R/R théo. : 1.88
// === TURTLE SOUP 1S – ITERATION 1 : SCALP AGRESSIF ===
// R/R théorique : 1.88 | Donchian:20 RSI:32/68 Stop:0.8 Target:1.5 Trail:0.4
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 20
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 0.8
ATR_Target = 1.5
TrailingRetrace = 0.4
RSI_Long = 32
RSI_Short = 68
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 25 | RSI : 30/70 | Stop : 1.0× ATR | Target : 2.0× ATR | Trailing : 0.5× ATR | R/R théo. : 2.00
// === TURTLE SOUP 1S – ITERATION 2 : ÉQUILIBRÉ COURT ===
// R/R théorique : 2.00 | Donchian:25 RSI:30/70 Stop:1 Target:2 Trail:0.5
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 25
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.0
ATR_Target = 2.0
TrailingRetrace = 0.5
RSI_Long = 30
RSI_Short = 70
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 30 | RSI : 32/68 | Stop : 1.2× ATR | Target : 2.0× ATR | Trailing : 0.6× ATR | R/R théo. : 1.67
// === TURTLE SOUP 1S – ITERATION 3 : RÉFÉRENCE V1.0 ===
// R/R théorique : 1.67 | Donchian:30 RSI:32/68 Stop:1.2 Target:2 Trail:0.6
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 30
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.2
ATR_Target = 2.0
TrailingRetrace = 0.6
RSI_Long = 32
RSI_Short = 68
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 30 | RSI : 28/72 | Stop : 1.2× ATR | Target : 2.5× ATR | Trailing : 0.6× ATR | R/R théo. : 2.08
// === TURTLE SOUP 1S – ITERATION 4 : FILTRES STRICTS ===
// R/R théorique : 2.08 | Donchian:30 RSI:28/72 Stop:1.2 Target:2.5 Trail:0.6
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 30
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.2
ATR_Target = 2.5
TrailingRetrace = 0.6
RSI_Long = 28
RSI_Short = 72
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 35 | RSI : 30/70 | Stop : 1.4× ATR | Target : 2.5× ATR | Trailing : 0.6× ATR | R/R théo. : 1.79
// === TURTLE SOUP 1S – ITERATION 5 : MOMENTUM MOYEN ===
// R/R théorique : 1.79 | Donchian:35 RSI:30/70 Stop:1.4 Target:2.5 Trail:0.6
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 35
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.4
ATR_Target = 2.5
TrailingRetrace = 0.6
RSI_Long = 30
RSI_Short = 70
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 35 | RSI : 32/68 | Stop : 1.2× ATR | Target : 3.0× ATR | Trailing : 0.7× ATR | R/R théo. : 2.50
// === TURTLE SOUP 1S – ITERATION 6 : TARGET ÉTENDU ===
// R/R théorique : 2.50 | Donchian:35 RSI:32/68 Stop:1.2 Target:3 Trail:0.7
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 35
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.2
ATR_Target = 3.0
TrailingRetrace = 0.7
RSI_Long = 32
RSI_Short = 68
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 40 | RSI : 30/70 | Stop : 1.4× ATR | Target : 2.8× ATR | Trailing : 0.7× ATR | R/R théo. : 2.00
// === TURTLE SOUP 1S – ITERATION 7 : SWING COURT ===
// R/R théorique : 2.00 | Donchian:40 RSI:30/70 Stop:1.4 Target:2.8 Trail:0.7
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 40
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.4
ATR_Target = 2.8
TrailingRetrace = 0.7
RSI_Long = 30
RSI_Short = 70
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 40 | RSI : 28/72 | Stop : 1.6× ATR | Target : 3.0× ATR | Trailing : 0.8× ATR | R/R théo. : 1.88
// === TURTLE SOUP 1S – ITERATION 8 : TREND-FOLLOWING ===
// R/R théorique : 1.88 | Donchian:40 RSI:28/72 Stop:1.6 Target:3 Trail:0.8
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 40
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.6
ATR_Target = 3.0
TrailingRetrace = 0.8
RSI_Long = 28
RSI_Short = 72
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 45 | RSI : 30/70 | Stop : 1.4× ATR | Target : 2.5× ATR | Trailing : 0.7× ATR | R/R théo. : 1.79
// === TURTLE SOUP 1S – ITERATION 9 : INTERMÉDIAIRE ===
// R/R théorique : 1.79 | Donchian:45 RSI:30/70 Stop:1.4 Target:2.5 Trail:0.7
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 45
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.4
ATR_Target = 2.5
TrailingRetrace = 0.7
RSI_Long = 30
RSI_Short = 70
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Donchian : 50 | RSI : 28/72 | Stop : 1.6× ATR | Target : 3.0× ATR | Trailing : 0.8× ATR | R/R théo. : 1.88
// === TURTLE SOUP 1S – ITERATION 10 : CONSERVATEUR ===
// R/R théorique : 1.88 | Donchian:50 RSI:28/72 Stop:1.6 Target:3 Trail:0.8
DEFPARAM CumulateOrders = False
// === PARAMÈTRES ===
LookbackDonchian = 50
RSI_Period = 8
ATR_Period = 14
MinVolMult = 1.2
ATR_Stop = 1.6
ATR_Target = 3.0
TrailingRetrace = 0.8
RSI_Long = 28
RSI_Short = 72
// === CALCULS ===
PrevDonchHigh = Highest[LookbackDonchian](High)[1]
PrevDonchLow = Lowest[LookbackDonchian](Low)[1]
MyATR = ATR[ATR_Period](Close)
MyRSI = RSI[RSI_Period](Close)
VolAvg = Average[30](Volume)
EMA5 = ExponentialAverage[5](Close)
EMA20 = ExponentialAverage[20](Close)
StopDist = MyATR * ATR_Stop
TargetDist = MyATR * ATR_Target
// === CONDITIONS ===
CondLong1 = Close < PrevDonchLow AND MyRSI < RSI_Long
CondLong2 = Volume > VolAvg * MinVolMult AND EMA5 > EMA20[3]
CondLong = CondLong1 AND CondLong2
CondShort1 = Close > PrevDonchHigh AND MyRSI > RSI_Short
CondShort2 = Volume > VolAvg * MinVolMult AND EMA5 < EMA20[3]
CondShort = CondShort1 AND CondShort2
// === ENTRÉES ===
IF CondLong AND NOT LongOnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF CondShort AND NOT ShortOnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// === SORTIES LONG (Trailing Option C) ===
IF LongOnMarket THEN
ProfitL = Close – PositionAveragePrice
MaxProfitL = MAX(ProfitL, MaxProfitL[1])
IF ProfitL >= TargetDist THEN
SELL AT MARKET
ELSIF MaxProfitL >= MyATR AND ProfitL < MaxProfitL – MyATR * TrailingRetrace THEN
SELL AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
// === SORTIES SHORT (Trailing Option C) ===
IF ShortOnMarket THEN
ProfitS = PositionAveragePrice – Close
MaxProfitS = MAX(ProfitS, MaxProfitS[1])
IF ProfitS >= TargetDist THEN
EXITSHORT AT MARKET
ELSIF MaxProfitS >= MyATR AND ProfitS < MaxProfitS – MyATR * TrailingRetrace THEN
EXITSHORT AT MARKET
ENDIF
SET STOP LOSS StopDist
ENDIF
Bonjour Paul,
Malheureusement, tous ces codes générés par IA comportent des erreurs. Pourriez vous svp nous indiquer ce que vous souhaiteriez obtenir svp ?
je comprends,
ce que je cherche c’est:
1 adapter mon code pour scalper audusd et eurusd
et surtout qu’il passe mes ordres……..
2 et utiliser le parabolique pour mes stop suiveurs en fonction de l’ATR
Sans trop de détails sur ce que doit faire la stratégie, voici une proposition d’une stratégie TurtleSoup (trading sur les faux breakout) avec un trailing stop basé sur le parabolic SAR:
// ============================================================
// TURTLE SOUP SCALPER FOREX — Trailing Stop Parabolic SAR
// Principe : exploiter le faux breakout du canal de Donchian
// Timeframe recommandé : M5 ou M15, paires majeures Forex
// ============================================================
DEFPARAM CumulateOrders = False
// --- Paramètres utilisateur (optimisables) ---
lookback = 20 // Période du canal Donchian pour détecter le breakout
sarAF = 0.02 // Facteur d'accélération initial du Parabolic SAR
sarStep = 0.02 // Incrément du facteur d'accélération
sarMax = 0.2 // Plafond du facteur d'accélération
atrPeriod = 14 // Période ATR pour calibrer les stops et le TP
riskMult = 1.5 // Stop initial = riskMult x ATR depuis le prix d'entrée
tpMult = 2.0 // Take profit = tpMult x ATR depuis le prix d'entrée
confirmBars = 2 // Bougies en arrière pour valider le faux breakout
// --- Canal de Donchian (excluant la bougie courante) ---
chanHigh = Highest[lookback](high[1])
chanLow = Lowest[lookback](low[1])
// --- Indicateurs ---
mySAR = SAR[sarAF, sarStep, sarMax]
myATR = AverageTrueRange[atrPeriod](close)
// --- Détection du Turtle Soup ---
// Long : cassure sous chanLow il y a confirmBars bougies, puis retour haussier
falseBreakDn = low[confirmBars] <= chanLow AND close > chanLow AND close > open
// Short : cassure au-dessus de chanHigh il y a confirmBars bougies, puis retour baissier
falseBreakUp = high[confirmBars] >= chanHigh AND close < chanHigh AND close < open
// --- Filtre SAR comme confirmation de direction ---
// On n'entre long que si le SAR est déjà sous le cours (SAR haussier)
// On n'entre short que si le SAR est déjà au-dessus du cours (SAR baissier)
sarLongOK = mySAR < close
sarShortOK = mySAR > close
// -----------------------------------------------
// ENTREES
// -----------------------------------------------
IF NOT LongOnMarket AND NOT ShortOnMarket THEN
IF falseBreakDn AND sarLongOK THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF falseBreakUp AND sarShortOK THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
ENDIF
// -----------------------------------------------
// SORTIES DYNAMIQUES PAR PARABOLIC SAR
// Dès que le SAR retourne contre la position, on sort
// C'est le coeur du trailing stop basé sur le SAR
// -----------------------------------------------
IF LongOnMarket AND mySAR > close THEN
SELL AT MARKET
ENDIF
IF ShortOnMarket AND mySAR < close THEN
EXITSHORT AT MARKET
ENDIF
// -----------------------------------------------
// STOP INITIAL DE SECURITE + TAKE PROFIT (en ATR)
// Garde-fou en cas de gap ou de volatilité extrême
// Ces niveaux sont fixes dès l'entrée en position
// -----------------------------------------------
IF LongOnMarket THEN
SET STOP LOSS (tradeprice - riskMult * myATR)
SET TARGET PROFIT (tradeprice + tpMult * myATR)
ENDIF
IF ShortOnMarket THEN
SET STOP LOSS (tradeprice + riskMult * myATR)
SET TARGET PROFIT (tradeprice - tpMult * myATR)
ENDIF
Voici comment fonctionne la logique complète :
Principe Turtle Soup :
Filtre Parabolic SAR à l’entrée :
Trailing stop SAR à la sortie :
Stop initial ATR + Take profit :
Conseils d’optimisation :
Turtle soup snail trading stratégie pour ProRealTime
This topic contains 10 replies,
has 4 voices, and was last updated by
Nicolas
2 days, 4 hours ago.
| Forum: | ProOrder : Trading Automatique & Backtests |
| Language: | French |
| Started: | 04/11/2026 |
| Status: | Active |
| Attachments: | No files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.