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. /// Définition des paramètres du code DEFPARAM CumulateOrders = False // Cumul des positions désactivé Timeframe (4 hours) //////////////////////////////////////////////////////////////////// parameters KAMA Period4h = 150 FastPeriod4h = 2 SlowPeriod4h = 30 Fastest4h = 2 / (FastPeriod4h + 1) Slowest4h = 2 / (SlowPeriod4h + 1) if barindex < Period4h+1 then Kama4h=close else Num4h= abs(close-close[Period4h]) Den4h = summation[Period4h](abs(close-close[1])) ER4h = Num4h / Den4h Alpha4h = SQUARE(ER4h *(Fastest4h - Slowest4h)+ Slowest4h) KAMA4h = (Alpha4h * Close) + ((1 -Alpha4h)* Kama4h[1]) endif KAMAUp4h = (KAMA4h > KAMA4H[1]) KAMADN4h = (KAMA4h < KAMA4H[1]) /////////////////////////////// Trend Envelopppes (développé par Nicolas) timePeriod4h=14 Deviation4h=0.1 price14h=customclose dsma4h = WeightedAverage[timePeriod4h](price14h) valuesHigh4h = (1 + deviation4h / 100) * dsma4h valuesLow4h = (1 - deviation4h / 100) * dsma4h inputs4h=price14h if (inputs4h > valuesHigh4h)then trendEnvelop4h = 1 elsif (inputs4h < valuesLow4h) then trendEnvelop4h = -1 endif TrendUp4h = kamaup4h and TrendEnvelop4h = 1 TrendDn4h = kamadn4h and TrendEnvelop4h = -1 Timeframe (15 minutes) //////////////////////////////////////////////////////////////////// parameters KAMA Period15min = 150 FastPeriod15min = 2 SlowPeriod15min = 30 Fastest15min = 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 KAMAUp15min = (KAMA15min > KAMA15min[1]) KAMADN15min = (KAMA15min < KAMA15min[1]) /////////////////////////////// Trend Envelopppes timePeriod15min=14 Deviation15min=0.1 price115min=customclose dsma15min = WeightedAverage[timePeriod15min](price115min) valuesHigh15min = (1 + deviation15min / 100) * dsma15min valuesLow15min = (1 - deviation15min / 100) * dsma15min inputs15min=price115min if (inputs15min > valuesHigh15min)then trendEnvelop15min = 1 elsif (inputs15min < valuesLow15min) then trendEnvelop15min = -1 endif // Keltner Channel periodMA15min=20 MA15min = ExponentialAverage[periodMA15min](close) //============================== Indicateur Heikin Ashi IV avec le vrai close //Hienkin IV if barindex>1 then haclosex15min=(open+close+low+high)/4 endif KeltnerUp15min = haclosex15min > MA15min KeltnerDn15min = haclosex15min < MA15min TrendSignalUp15min = KAMAUp15min and KeltnerUp15min and trendEnvelop15min = 1 TrendSignalDn15min = KAMADn15min and KeltnerDn15min and trendEnvelop15min = -1 if TrendUp4h and TrendSignalUp15min then buy 1 contract at market endif if TrendDn4h and TrendSignalDn15min then sellshort 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