Système ne prenant pas la tendance baissière
Forums › ProRealTime forum Français › Support ProOrder › Système ne prenant pas la tendance baissière
- This topic has 19 replies, 5 voices, and was last updated 1 year ago by Nicolas.
-
-
06/24/2023 at 10:03 AM #216687
Bonjour,
j’ai un petit souci avec ce bout de programme. Il ne prend de “position short” lorsqu’en UT 4h la kama 150 & trendEnvelop4h = -1
Je n’arrive pas à voir où ça coince.
Si quelqu’un a une idée, merci d’avance.
Programme123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159/// Définition des paramètres du codeDEFPARAM CumulateOrders = False // Cumul des positions désactivéTimeframe (4 hours)//////////////////////////////////////////////////////////////////// parameters KAMAPeriod4h = 150FastPeriod4h = 2SlowPeriod4h = 30Fastest4h = 2 / (FastPeriod4h + 1)Slowest4h = 2 / (SlowPeriod4h + 1)if barindex < Period4h+1 thenKama4h=closeelseNum4h= abs(close-close[Period4h])Den4h = summation[Period4h](abs(close-close[1]))ER4h = Num4h / Den4hAlpha4h = SQUARE(ER4h *(Fastest4h - Slowest4h)+ Slowest4h)KAMA4h = (Alpha4h * Close) + ((1 -Alpha4h)* Kama4h[1])endifKAMAUp4h = (KAMA4h > KAMA4H[1])KAMADN4h = (KAMA4h < KAMA4H[1])/////////////////////////////// Trend Envelopppes (développé par Nicolas)timePeriod4h=14Deviation4h=0.1price14h=customclosedsma4h = WeightedAverage[timePeriod4h](price14h)valuesHigh4h = (1 + deviation4h / 100) * dsma4hvaluesLow4h = (1 - deviation4h / 100) * dsma4hinputs4h=price14hif (inputs4h > valuesHigh4h)thentrendEnvelop4h = 1elsif (inputs4h < valuesLow4h) thentrendEnvelop4h = -1endifTrendUp4h = kamaup4h and TrendEnvelop4h = 1TrendDn4h = kamadn4h and TrendEnvelop4h = -1Timeframe (15 minutes)//////////////////////////////////////////////////////////////////// parameters KAMAPeriod15min = 150FastPeriod15min = 2SlowPeriod15min = 30Fastest15min = 2 / (FastPeriod15min + 1)Slowest15min = 2 / (SlowPeriod15min + 1)if barindex < Period15min+1 thenKama15min=closeelseNum15min = abs(close-close[Period15min])Den15min = summation[Period15min](abs(close-close[1]))ER15min = Num15min / Den15minAlpha15min = SQUARE(ER15min *(Fastest15min - Slowest15min)+ Slowest15min)KAMA15min = (Alpha15min * Close) + ((1 -Alpha15min)* Kama15min[1])endifKAMAUp15min = (KAMA15min > KAMA15min[1])KAMADN15min = (KAMA15min < KAMA15min[1])/////////////////////////////// Trend EnvelopppestimePeriod15min=14Deviation15min=0.1price115min=customclosedsma15min = WeightedAverage[timePeriod15min](price115min)valuesHigh15min = (1 + deviation15min / 100) * dsma15minvaluesLow15min = (1 - deviation15min / 100) * dsma15mininputs15min=price115minif (inputs15min > valuesHigh15min)thentrendEnvelop15min = 1elsif (inputs15min < valuesLow15min) thentrendEnvelop15min = -1endif// Keltner ChannelperiodMA15min=20MA15min = ExponentialAverage[periodMA15min](close)//============================== Indicateur Heikin Ashi IV avec le vrai close//Hienkin IVif barindex>1 thenhaclosex15min=(open+close+low+high)/4endifKeltnerUp15min = haclosex15min > MA15minKeltnerDn15min = haclosex15min < MA15minTrendSignalUp15min = KAMAUp15min and KeltnerUp15min and trendEnvelop15min = 1TrendSignalDn15min = KAMADn15min and KeltnerDn15min and trendEnvelop15min = -1if TrendUp4h and TrendSignalUp15min thenbuy 1 contract at marketendifif TrendDn4h and TrendSignalDn15min thensellshort 1 contract at marketendif//trailing stop functiontrailingstart = 5 //trailing will start @trailinstart points profittrailingstep = 5 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THENIF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF1 user thanked author for this post.
06/24/2023 at 10:15 AM #216688Bonjour,
Le problème que vous rencontrez dans votre code réside dans la condition
TrendDn4h and TrendSignalDn15min
pour l’ouverture d’une position short. Dans cette condition, vous avez utiliséTrendSignalDn15min
qui est basé surKAMADn15min
, alors que dans votre code, vous utilisezKAMADN15min
(avec des majuscules).Il suffit de modifier la condition comme suit je crois :
if TrendDn4h and KAMADN15min then
sellshort 1 contract at market
endif1 user thanked author for this post.
06/24/2023 at 10:22 AM #21668906/24/2023 at 10:53 AM #216690Après avoir examiné à nouveau votre code, j’ai identifié un autre problème potentiel. Vous utilisez
TrendDn4h
pour vérifier la tendance baissière dans la conditionif TrendDn4h and KAMADN15min then
, maisTrendDn4h
est basé surkamadn4h
(avec des minuscules), alors que vous utilisezKAMADN15min
(avec des majuscules).Veuillez modifier la condition comme suit :
if kamadn4h and KAMADN15min then
sellshort 1 contract at market
endif
Avec cette modification, le code devrait prendre une position short lorsque
kamadn4h
est vrai et que la conditionKAMADN15min
est également vraie.06/24/2023 at 12:29 PM #216697Rebonjour,
non cela ne fonctionne toujours pas. Je ne crois pas que les lignes de programme soient sensibles au minuscule et au majuscule. Je pense qu’il y a une erreur évidente mais que je ne vois pas (d’autant plus que ces quelques lignes de code sont hyper simples).
06/24/2023 at 1:47 PM #216698j ai fait un BT sur dax 15 min, j ai des positions short. (dans l’état de votre code est publié ici).
06/24/2023 at 1:56 PM #21669906/24/2023 at 3:28 PM #21670006/24/2023 at 4:57 PM #21670106/24/2023 at 5:12 PM #21670206/25/2023 at 6:53 PM #216736Code 4h 1 h123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335// Définition des paramètres du codeDEFPARAM CumulateOrders = False // Cumul des positions désactivé//PRC_BuySell MagicBuySell Magic | indicator//17.04.23//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//// Starting from: https://www.prorealcode.com/prorealtime-indicators/buysell-magical-trend/// Screener at user request 05.05.23 JC_Bywan https://www.prorealcode.com/topic/screener-buy-sell-magic-indicator///PRC_BuySell MagicBuySell Magic | indicator//17.04.23//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//// Starting from: https://www.prorealcode.com/prorealtime-indicators/buysell-magical-trend/// Screener at user request 05.05.23 JC_Bywan https://www.prorealcode.com/topic/screener-buy-sell-magic-indicator/Timeframe (4 hours)//////////////////////////////////////////////////////////////////// parameters KAMAPeriod4h = 150FastPeriod4h = 2SlowPeriod4h = 30Fastest4h = 2 / (FastPeriod4h + 1)Slowest4h = 2 / (SlowPeriod4h + 1)if barindex < Period4h+1 thenKama4h=closeelseNum4h = abs(close-close[Period4h])Den4h = summation[Period4h](abs(close-close[1]))ER4h = Num4h / Den4hAlpha4h = SQUARE(ER4h *(Fastest4h - Slowest4h )+ Slowest4h)KAMA4h = (Alpha4h * Close) + ((1 -Alpha4h)* Kama4h[1])endifKAMAUp4h = (KAMA4h > KAMA4H[1])KAMADN4h = (KAMA4h < KAMA4H[1])/////////////////////////////// Trend Envelopppes (développé par Nicolas)timePeriod4h=14Deviation4h=0.1price14h=customclosedsma4h = WeightedAverage[timePeriod4h](price14h)valuesHigh4h = (1 + deviation4h / 100) * dsma4hvaluesLow4h = (1 - deviation4h / 100) * dsma4hinputs4h=price14hif (inputs4h > valuesHigh4h)thentrendEnvelop4h = 1elsif (inputs4h < valuesLow4h) thentrendEnvelop4h = -1endif// Keltner ChannelperiodMA4h=20MA4h = ExponentialAverage[periodMA4h](close)//============================== Indicateur Heikin Ashi IV avec le vrai close//Hienkin IVif barindex>1 thenhaclosex4h=(open+close+low+high)/4endifKeltnerUp4h = haclosex4h > MA4hKeltnerDn4h = haclosex4h < MA4h//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//// Starting from library: https://www.prorealcode.com/prorealtime-indicators/buysell-magical-trend/// Screener at user request 05.05.23 JC_Bywan @ www.prorealcode.com// https://www.prorealcode.com/topic/screener-buy-sell-magic-indicator/// --- settingsSignalPeriod4h = 12ArrowPeriod4h = 2// --- end of settingsbbup4h = average[signalperiod4h]+std[signalperiod4h]*arrowperiod4hbbdn4h = average[signalperiod4h]-std[signalperiod4h]*arrowperiod4hif ts4h=0 thenif close crosses over bbup4h thents4h=bbdn4htrendSignal4h=1elsif close crosses under bbdn4h thents4h=bbup4htrendSignal4h=-1endifendifif trendSignal4h=1 thents4h=max(ts4h,bbdn4h)elsif trendSignal4h=-1 thents4h=min(ts4h,bbup4h)endifif trendSignal4h=1 and close crosses under ts4h thentrendSignal4h=-1ts4h=bbup4h//r=255//g=0//drawarrowdown(barindex,ts) coloured("red")//drawsegment(startbar,startts,barindex,ts) style(dottedline2) coloured("blue")//startbar=barindex//startts=tsendifif trendSignal4h=-1 and close crosses over ts4h thentrendSignal4h=1ts4h=bbdn4h//r=0//g=255//drawarrowup(barindex,ts) coloured("lime")//drawsegment(startbar,startts,barindex,ts) style(dottedline2) coloured("blue")//startbar=barindex//startts=tsendifcup4h= trendSignal4h[1]=-1 and trendSignal4h=1cdown4h= trendSignal4h[1]=1 and trendSignal4h=-1TrendMagicalUp4h = cup4h or cup4h[1] or cup4h[2]TrendMagicalDn4h = cdown4h or cdown4h[1] or cdown4h[2]/////////////////////////////////////////////////// Trend4h paramètresTrendSignalUp4h = KAMAUp4h and KeltnerUp4h and trendEnvelop4h = 1TrendSignalDn4h = KAMADn4h and KeltnerDn4h and trendEnvelop4h = -1Timeframe (1 hour)//////////////////////////////////////////////////////////////////// parameters KAMAPeriod1h = 150FastPeriod1h = 2SlowPeriod1h = 30Fastest1h = 2 / (FastPeriod1h + 1)Slowest1h = 2 / (SlowPeriod1h + 1)if barindex < Period1h+1 thenKama1h=closeelseNum1h = abs(close-close[Period1h])Den1h = summation[Period1h](abs(close-close[1]))ER1h = Num1h / Den1hAlpha1h = SQUARE(ER1h *(Fastest1h - Slowest1h )+ Slowest1h)KAMA1h = (Alpha1h * Close) + ((1 -Alpha1h)* Kama1h[1])endifKAMAUp1h = (KAMA1h > KAMA1H[1])KAMADN1h = (KAMA1h < KAMA1H[1])/////////////////////////////// Trend Envelopppes (développé par Nicolas)timePeriod1h=14Deviation1h=0.1price11h=customclosedsma1h = WeightedAverage[timePeriod1h](price11h)valuesHigh1h = (1 + deviation1h / 100) * dsma1hvaluesLow1h = (1 - deviation1h / 100) * dsma1hinputs1h=price11hif (inputs1h > valuesHigh1h)thentrendEnvelop1h = 1elsif (inputs1h < valuesLow1h) thentrendEnvelop1h = -1endif// Keltner ChannelperiodMA1h=20MA1h = ExponentialAverage[periodMA1h](close)//============================== Indicateur Heikin Ashi IV avec le vrai close//Hienkin IVif barindex>1 thenhaclosex1h=(open+close+low+high)/4endifKeltnerUp1h = haclosex1h > MA1hKeltnerDn1h = haclosex1h < MA1h//17.04.23//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//// Starting from library: https://www.prorealcode.com/prorealtime-indicators/buysell-magical-trend/// Screener at user request 05.05.23 JC_Bywan @ www.prorealcode.com// https://www.prorealcode.com/topic/screener-buy-sell-magic-indicator/// --- settingsSignalPeriod1h = 12ArrowPeriod1h = 2// --- end of settingsbbup1h = average[signalperiod1h]+std[signalperiod1h]*arrowperiod1hbbdn1h = average[signalperiod1h]-std[signalperiod1h]*arrowperiod1hif ts1h=0 thenif close crosses over bbup1h thents1h=bbdn1htrendSignal1h=1elsif close crosses under bbdn1h thents1h=bbup1htrendSignal1h=-1endifendifif trendSignal1h=1 thents1h=max(ts1h,bbdn1h)elsif trendSignal1h=-1 thents1h=min(ts1h,bbup1h)endifif trendSignal1h=1 and close crosses under ts1h thentrendSignal1h=-1ts1h=bbup1h//r=255//g=0//drawarrowdown(barindex,ts) coloured("red")//drawsegment(startbar,startts,barindex,ts) style(dottedline2) coloured("blue")//startbar=barindex//startts=tsendifif trendSignal1h=-1 and close crosses over ts1h thentrendSignal1h=1ts1h=bbdn1h//r=0//g=255//drawarrowup(barindex,ts) coloured("lime")//drawsegment(startbar,startts,barindex,ts) style(dottedline2) coloured("blue")//startbar=barindex//startts=tsendifcup1h= trendSignal1h[1]=-1 and trendSignal1h=1cdown1h= trendSignal1h[1]=1 and trendSignal1h=-1TrendMagicalUp1h = cup1h or cup1h[1] or cup1h[2]TrendMagicalDn1h = cdown1h or cdown1h[1] or cdown1h[2]/////////////////////////////////////////////////// Trend1h paramètresTrendSignalUp1h = KAMAUp1h and KeltnerUp1h and trendEnvelop1h = 1TrendSignalDn1h = KAMADn1h and KeltnerDn1h and trendEnvelop1h = -1BuySignal1h = TrendMagicalUp1h and trendSignalUp1h and trendSignalUp4hSellSignal1h = TrendMagicalDn1h and trendSignalDn1H and trendSignalDn4hBuySignal4h = TrendMagicalUp4h and trendSignalUp1h and trendSignalUp4hSellSignal4h = TrendMagicalDn4h and trendSignalDn1H and trendSignalDn4hif BuySignal1h thenbuy 1 contract at marketendifif SellSignal1h thensellshort 1 contract at marketendif//trailing stop functiontrailingstart = 5 //trailing will start @trailinstart points profittrailingstep = 5 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THENIF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFJe reviens avec mon programme : je joints donc le code en 4h et 1h et une pièce jointe pour montrer que le système prend bien une position vendeuse le 20 juin à 14 heures (je suis sur XAU / USD). Par contre, dans le code quand je change timeframe (1 hour) par timeframe (15 minutes) et que je lance bien mon back testing avec les UT 4h et 15 min et bien aucune position short n’est prise. Je ne comprends pas pourquoi.
06/25/2023 at 7:54 PM #21673806/25/2023 at 8:18 PM #21674306/25/2023 at 8:26 PM #21674408/23/2023 at 3:07 PM #219549merci pour ce partage ;
la strat s’avère perdante sur du H1 malheureusement sauf erreur ;
-
AuthorPosts
Find exclusive trading pro-tools on