Entrée longue en erreur
Forums › ProRealTime forum Français › Support ProBuilder › Entrée longue en erreur
- This topic has 11 replies, 3 voices, and was last updated 9 months ago by finplus. 
- 
	
		
- 
		
			
				
01/18/2025 at 12:43 PM #242752"entrer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778kama1h et kama15min" >/// Définition des paramètres du codeDEFPARAM CumulateOrders = False // Cumul des positions désactivéTimeframe (1 hour)Period1h = 150FastPeriod1h = 2SlowPeriod1h = 50Fastest1h = 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])endifTimeframe (15 minutes)/////////////////////////////////////////////////////////////////// parameters KAMAPeriod4h = 150FastPeriod4h = 2SlowPeriod4h = 50Fastest4h = 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])endif//-------------------------------------////PRC_RSI Cyclic Smoothed//version = 0//19.11.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------////Inputs//-------------------------------------//src4h=closedomcycle4h=20cyclelen4h=domcycle4h/2vibration4h=10leveling4h=10cyclicmemory4h=domcycle4h*2once crsi4h=0//-------------------------------------//// CRSI calculation//-------------------------------------//torque4h=2/(vibration4h+1)phasinglag4h=floor((vibration4h-1)/2)length4h = cyclelen4halpha4h = 1/length4hsrcUp4h = max(src4h-src4h[1],0)if barindex = length4h thenup4h = average[length4h](srcUp4h)elseup4h = alpha4h*srcUp4h + (1-alpha4h)*up4h[1]endifsrcDw4h = -min(src4h-src4h[1],0)if barindex = length4h thendw4h = average[length4h](srcdw4h)Bonjour, je rencontre un problème dans ce code. Je souhaiterai entrer long lorsque les cours sont au-dessus des Kama 150 sur les unités de temps 1h et 15 min. Or en faisant un back test, une entrée longue a été faite le 25 novembre 2024 (et ce n’est pas la seule date qui pose problème). Or d’après mon graphique en 1 heure, les cours étaient au dessous de la kama150 à cette période. Pourriez-vous m’indiquer ce qui cloche dans mon code ? merci. 01/18/2025 at 12:54 PM #242753le code en entier Timeframe (1 hour) Period1h = 150 
 FastPeriod1h = 2
 SlowPeriod1h = 50Fastest1h = 2 / (FastPeriod1h + 1) 
 Slowest1h = 2 / (SlowPeriod1h + 1)
 if barindex < Period1h+1 then
 Kama1h=close
 else
 Num1h = abs(close-close[Period1h])
 Den1h = summation[Period1h](abs(close-close[1]))
 ER1h = Num1h / Den1h
 Alpha1h = SQUARE(ER1h *(Fastest1h – Slowest1h )+ Slowest1h)
 KAMA1h = (Alpha1h * Close) + ((1 -Alpha1h)* Kama1h[1])
 endifTimeframe (15 minutes) 
 /////////////////////////////////////////////////////////////////// parameters KAMAPeriod15min = 150 
 FastPeriod15min = 2
 SlowPeriod15min = 50Fastest15min = 2 / (FastPeriod15min + 1) 
 Slowest15min = 2 / (SlowPeriod15min + 1)
 if barindex < Period15min+1 then
 Kama15min=close
 else
 Num15min = abs(close-close[Period15min])
 Den15min = summation[Period15min](abs(close-close[1]))
 ER15min = Num15min / Den15min
 Alpha15min = SQUARE(ER15min *(Fastest15min – Slowest15min )+ Slowest15min)
 KAMA15min = (Alpha15min * Close) + ((1 -Alpha15min)* Kama15min[1])
 endif//————————————-// 
 //PRC_RSI Cyclic Smoothed
 //version = 0
 //19.11.2024
 //Iván González @ http://www.prorealcode.com
 //Sharing ProRealTime knowledge
 //————————————-//
 //Inputs
 //————————————-//
 src15min=close
 domcycle15min=20
 cyclelen15min=domcycle15min/2
 vibration15min=10
 leveling15min=10
 cyclicmemory15min=domcycle15min*2once crsi15min=0 
 //————————————-//
 // CRSI calculation
 //————————————-//
 torque15min=2/(vibration15min+1)
 phasinglag15min=floor((vibration15min-1)/2)length15min = cyclelen15min 
 alpha15min = 1/length15minsrcUp15min = max(src15min-src15min[1],0) 
 if barindex = length15min then
 up15min = average[length15min](srcUp15min)
 else
 up15min = alpha15min*srcUp15min + (1-alpha15min)*up15min[1]
 endifsrcDw15min = -min(src15min-src15min[1],0) 
 if barindex = length15min then
 dw15min = average[length15min](srcdw15min)
 else
 dw15min = alpha15min*srcdw15min + (1-alpha15min)*dw15min[1]
 endifif dw15min=0 then 
 myrsi15min=100
 elsif up15min=0 then
 myrsi15min=0
 else
 myrsi15min=100-100/(1+up15min/dw15min)
 endif
 if barindex>cyclicmemory15min then
 crsi15min=torque15min*(2*myrsi15min-myrsi15min[phasinglag15min])+(1-torque15min)*crsi15min[1]
 endif
 //————————————-//
 // LowBand and HighBand calculation
 //————————————-//
 Period15min=cyclicMemory15min
 percent15min = leveling15min/100
 periodMinusone15min = period15min-1
 maxima15min = -999999.0
 minima15min = 999999.0for i15min=0 to periodMinusone15min do if crsi15min[i15min] > maxima15min then 
 maxima15min = crsi15min[i15min]
 elsif crsi15min[i15min] < minima15min then
 minima15min = crsi15min[i15min]
 endif
 nextstepfactor15min = (maxima15min-minima15min)/100 
 lowband15min = 0for steps15min=0 to 100 do 
 testvalue15min = minima15min+stepfactor15min*steps15min
 below15min=0
 for m15min=0 to periodMinusone15min do
 if crsi15min[m15min]<testvalue15min then
 below15min=below15min+1
 endif
 next
 if below15min/period15min >= percent15min then
 lowband15min = testvalue15min
 break
 endif
 nexthighband15min=0 
 for steps15min=0 to 100 do
 testvalue15min=maxima15min-stepfactor15min*steps15min
 above15min=0
 for m15min=0 to periodMinusone15min do
 if crsi15min[m15min]>=testvalue15min then
 above15min=above15min+1
 endif
 next
 if above15min/Period15min >= percent15min then
 highband15min=testvalue15min
 break
 endif
 nextmbb15min = average[50](crsi15min) 
 CRSISmooth15min = average[7](crsi15min)LongPos = (kama1h > kama1h[1]) and (close > kama1h) and (kama15min > kama15min[1]) and (close > kama15min) and (CRSI15min crosses over CRSISmooth15min) if longpos then 
 buy 1 contract at market
 endif///trailing stop function 
 trailingstart = 5 //trailing will start @trailinstart points profit
 trailingstep = 5 //trailing step to move the “stoploss”//reset the stoploss value 
 IF NOT ONMARKET THEN
 newSL=0
 ENDIF//manage long positions 
 IF LONGONMARKET THEN
 IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
 newSL = tradeprice(1)+trailingstep*pipsize
 ENDIF
 //next moves
 IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
 newSL = newSL+trailingstep*pipsize
 ENDIF
 ENDIF//manage short positions 
 IF SHORTONMARKET THEN
 //first move (breakeven)
 IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
 newSL = tradeprice(1)-trailingstep*pipsize
 ENDIF
 //next moves
 IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
 newSL = newSL-trailingstep*pipsize
 ENDIF
 ENDIF//stop order to exit the positions 
 IF newSL>0 THEN
 SELL AT newSL STOP
 EXITSHORT AT newSL STOP
 ENDIF// points based STOP LOSS and TRAILING STOP 
 // initial STOP LOSS
 SET STOP pLOSS 50// trailing stop 
 SET STOP pTRAILING 5001/18/2025 at 4:41 PM #24275401/18/2025 at 4:49 PM #242759Voici mon système (J’ai ajouté UPDATEONCLOSE aux deux timeframe, puis j’ai ajouté le timeframe défaut): 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193Timeframe (1 hour,updateonclose)Period1h = 150FastPeriod1h = 2SlowPeriod1h = 50Fastest1h = 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])endifTimeframe (15 minutes,updateonclose)/////////////////////////////////////////////////////////////////// parameters KAMAPeriod15min = 150FastPeriod15min = 2SlowPeriod15min = 50Fastest15min = 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])endif//————————————-////PRC_RSI Cyclic Smoothed//version = 0//19.11.2024//Iván González @ http://www.prorealcode.com//Sharing ProRealTime knowledge//————————————-////Inputs//————————————-//src15min=closedomcycle15min=20cyclelen15min=domcycle15min/2vibration15min=10leveling15min=10cyclicmemory15min=domcycle15min*2once crsi15min=0//————————————-//// CRSI calculation//————————————-//torque15min=2/(vibration15min+1)phasinglag15min=floor((vibration15min-1)/2)length15min = cyclelen15minalpha15min = 1/length15minsrcUp15min = max(src15min-src15min[1],0)if barindex = length15min thenup15min = average[length15min](srcUp15min)elseup15min = alpha15min*srcUp15min + (1-alpha15min)*up15min[1]endifsrcDw15min = -min(src15min-src15min[1],0)if barindex = length15min thendw15min = average[length15min](srcdw15min)elsedw15min = alpha15min*srcdw15min + (1-alpha15min)*dw15min[1]endifif dw15min=0 thenmyrsi15min=100elsif up15min=0 thenmyrsi15min=0elsemyrsi15min=100-100/(1+up15min/dw15min)endifif barindex>cyclicmemory15min thencrsi15min=torque15min*(2*myrsi15min-myrsi15min[phasinglag15min])+(1-torque15min)*crsi15min[1]endif//————————————-//// LowBand and HighBand calculation//————————————-//Period15min=cyclicMemory15minpercent15min = leveling15min/100periodMinusone15min = period15min-1maxima15min = -999999.0minima15min = 999999.0for i15min=0 to periodMinusone15min doif crsi15min[i15min] > maxima15min thenmaxima15min = crsi15min[i15min]elsif crsi15min[i15min] < minima15min thenminima15min = crsi15min[i15min]endifnextstepfactor15min = (maxima15min-minima15min)/100lowband15min = 0for steps15min=0 to 100 dotestvalue15min = minima15min+stepfactor15min*steps15minbelow15min=0for m15min=0 to periodMinusone15min doif crsi15min[m15min]<testvalue15min thenbelow15min=below15min+1endifnextif below15min/period15min >= percent15min thenlowband15min = testvalue15minbreakendifnexthighband15min=0for steps15min=0 to 100 dotestvalue15min=maxima15min-stepfactor15min*steps15minabove15min=0for m15min=0 to periodMinusone15min doif crsi15min[m15min]>=testvalue15min thenabove15min=above15min+1endifnextif above15min/Period15min >= percent15min thenhighband15min=testvalue15minbreakendifnextmbb15min = average[50](crsi15min)CRSISmooth15min = average[7](crsi15min)LongPos = (kama1h > kama1h[1]) and (close > kama1h) and (kama15min > kama15min[1]) and (close > kama15min) and (CRSI15min crosses over CRSISmooth15min)if longpos thenbuy 1 contract at marketendifTimeframe (default)///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 STOPENDIF// points based STOP LOSS and TRAILING STOP// initial STOP LOSSSET STOP pLOSS 50// trailing stopSET STOP pTRAILING 5001/18/2025 at 5:30 PM #24278401/18/2025 at 5:31 PM #24278501/18/2025 at 5:37 PM #242789Pour les premières vérifications de code, 5K unités peuvent être suffisants, mais lorsque vous effectuez des backtests définitifs, je vous recommande d’en utiliser beaucoup plus. J’utilise 200K (le maximum). 1 user thanked author for this post.01/18/2025 at 5:40 PM #24279001/18/2025 at 5:59 PM #24279201/18/2025 at 6:12 PM #24279401/19/2025 at 4:37 PM #242816D’accord. merci pour la rapidité de la réponse. Une dernière demande : l’indicateur corrigé par vous est-il transposable en screener ? Si oui, je ferai une demande dans le forum adéquat. Essaye ça. Je ne sais pas si le résultat sera correct, car les screeners n’ont pas UPDATEONCLOSE : 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148Timeframe (1 hour)Period1h = 150FastPeriod1h = 2SlowPeriod1h = 50Fastest1h = 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])endifTimeframe (15 minutes)/////////////////////////////////////////////////////////////////// parameters KAMAPeriod15min = 150FastPeriod15min = 2SlowPeriod15min = 50Fastest15min = 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])endif//————————————-////PRC_RSI Cyclic Smoothed//version = 0//19.11.2024//Iván González @ http://www.prorealcode.com//Sharing ProRealTime knowledge//————————————-////Inputs//————————————-//src15min=closedomcycle15min=20cyclelen15min=domcycle15min/2vibration15min=10leveling15min=10cyclicmemory15min=domcycle15min*2once crsi15min=0//————————————-//// CRSI calculation//————————————-//torque15min=2/(vibration15min+1)phasinglag15min=floor((vibration15min-1)/2)length15min = cyclelen15minalpha15min = 1/length15minsrcUp15min = max(src15min-src15min[1],0)if barindex = length15min thenup15min = average[length15min](srcUp15min)elseup15min = alpha15min*srcUp15min + (1-alpha15min)*up15min[1]endifsrcDw15min = -min(src15min-src15min[1],0)if barindex = length15min thendw15min = average[length15min](srcdw15min)elsedw15min = alpha15min*srcdw15min + (1-alpha15min)*dw15min[1]endifif dw15min=0 thenmyrsi15min=100elsif up15min=0 thenmyrsi15min=0elsemyrsi15min=100-100/(1+up15min/dw15min)endifif barindex>cyclicmemory15min thencrsi15min=torque15min*(2*myrsi15min-myrsi15min[phasinglag15min])+(1-torque15min)*crsi15min[1]endif//————————————-//// LowBand and HighBand calculation//————————————-//Period15min=cyclicMemory15minpercent15min = leveling15min/100periodMinusone15min = period15min-1maxima15min = -999999.0minima15min = 999999.0for i15min=0 to periodMinusone15min doif crsi15min[i15min] > maxima15min thenmaxima15min = crsi15min[i15min]elsif crsi15min[i15min] < minima15min thenminima15min = crsi15min[i15min]endifnextstepfactor15min = (maxima15min-minima15min)/100//lowband15min = 0for steps15min=0 to 100 dotestvalue15min = minima15min+stepfactor15min*steps15minbelow15min=0for m15min=0 to periodMinusone15min doif crsi15min[m15min]<testvalue15min thenbelow15min=below15min+1endifnextif below15min/period15min >= percent15min then//lowband15min = testvalue15minbreakendifnext//highband15min=0for steps15min=0 to 100 dotestvalue15min=maxima15min-stepfactor15min*steps15minabove15min=0for m15min=0 to periodMinusone15min doif crsi15min[m15min]>=testvalue15min thenabove15min=above15min+1endifnextif above15min/Period15min >= percent15min then//highband15min=testvalue15minbreakendifnext//mbb15min = average[50](crsi15min)CRSISmooth15min = average[7](crsi15min)LongPos = (kama1h > kama1h[1]) and (close > kama1h) and (kama15min > kama15min[1]) and (close > kama15min) and (CRSI15min crosses over CRSISmooth15min)Signal = 0if longpos thenSignal = 1endifSCREENER[Signal]01/19/2025 at 5:00 PM #242821
- 
		AuthorPosts
			Find exclusive trading pro-tools on 


 
 
 
		 
		 
		