// BT Exemple Strategie plbourse // Dimensionnement du SL à 4ATR, mini 3 % // pas de réactualisation du StopLoss // Pas de vente à R1 // Pas de pyramidage // conditions sur les dates DateDebut = 20110101 DateFin = 20201231 DateArret = 20210630 CondDate = (Date >= DateDebut) and (Date < DateFin) // definition du seuil de pente Once SeuilPenteEntree = 0.1 Once SeuilPenteSortie = 0.02 Once SeuilAmpliDir = 20 // définition des paramètres en journalier pour la détection de BO en weekly* // Valeur de référence ValHigh10 = Highest[10](high[1]) ValHigh25 = Highest[10](high[1]) CloseD = close CloseD1 = close[1] // Passage en weekly timeframe(weekly) if close>=average[20]+0.75*std[20] then scorew=2000 else scorew = 0 endif Nbweeks = barindex-1 // on ne considère pas la barre courante // limitation pour le screener à 250 barres d'historique if Nbweeks >= 250 then Nbweeks = 250 endif Indexweek = 0 //Initialisation de la condition du BO CondBOw = 0 While Indexweek < (Nbweeks - 1) and CondBOw = 0 Do Indexweek = indexweek + 1 ValHighWeeks = Highest[indexweek](high[1]) If (ValHighWeeks >= ValHigh10) and (CloseD >= ValHighWeeks) and (CloseD1 < ValHighWeeks) and (ValHighWeeks > high[indexweek + 1]) then CondBOw = 1 endif // Fin de While.... Wend // fin du mode weekly // Passage en Monthly, après le passage en weekly timeframe(monthly) if close>=average[20]+0.75*std[20] then scorem=4000 else scorem = 0 endif // Detection de BO en Monthly, on reprend le script de weekly, seulement si CondBOw est faux CondBOm = 0 CondBOath = 0 if CondBOw = 0 then Indexmonth = 0 Nbmonths = barindex-1 // on ne considère pas la barre courante // limitation pour le screener à 250 barres d'historique if Nbmonths >= 250 then Nbmonths = 250 endif While Indexmonth < (Nbmonths - 1) and CondBOm = 0 Do Indexmonth = indexmonth + 1 ValHighMonths = Highest[indexmonth](high[1]) //ValBOm = max(ValHighMonths, ValHigh25) If (ValHighMonths >= ValHigh25) and (CloseD >= ValHighMonths) and (CloseD1 < ValHighMonths) and (ValHighMonths > high[indexmonth + 1]) then CondBOm = 1 endif // Fin de While.... Wend // fin de if CondBOw = 0 endif If CloseD > max(highest[NbMonths](high[1]), ValHigh25) then CondBOath = 1 endif // fin du mode monthly // passage en daily Timeframe(daily) if close>=average[20]+0.75*std[20] then scored=1000 else scored = 0 endif // Traitement de ExtraTrend pour myLowSignal myTrend, myLowSignal, myExpansion, ignored, ignored = Call "ExtraTrend"[0, 0, 0, 0, 0, 0](close) // Calcul du taux de pente et des conditions sur la pente MM200 = Average[200](Close) MM200Old = MM200[20] Pente = (MM200 -MM200old)/MM200/20*100 CondPente = Pente >= SeuilPenteEntree // défininition de la vitesse vitesse=round(highest[100](roc[20])) score=scorem + scorew + scored + vitesse // Calcul de l'amplitude Directionnelle selon Tino bb = Bollingerup[30] - BollingerDown[30] Pbb = bb/BollingerDown[30] * 100 Pmbb = Average[200](Pbb) CondAmpliDir = (Pmbb >= SeuilAmpliDir) // condition sur les volumes de transaction okvolume=average[20](close*volume)>300000 // condition sur les bougies opa=highest[5](high)/lowest[5](low)<1.03 // Condition depuis la dernière sortie CondLastTrade = 1 For j = 1 to 30 if LongonMarket[j] then CondLastTrade = 0 endif next CondAch = CondDate CondAch = CondAch and (score >= 3000) and (vitesse >= 25) CondAch = CondAch and okvolume CondAch = CondAch and not opa CondAch = CondAch and CondPente CondAch = CondAch and (CondBOw or CondBOm or CondBOath) CondAch = CondAch and CondAmpliDir CondAch = CondAch and CondLastTrade // conditions de ventes et revision du StopLoss // Definition du cours d'achat if LongonMarket and Not LongonMarket[1] then Entryprice = open R = Entryprice - Stoplossini R1 = 2*entryprice - StoplossIni endif // Sortie sur Stoploss if Longonmarket and LongonMarket[1] then Sell at StopLoss stop endif // Sortie sur perte de pente if onMarket and Pente crosses under SeuilPenteSortie then Sell at market endif // Vente à R1 et déclenchement de la reconnaissance de la vente à R1 if LongonMarket and (condtradegratuit = 0) and (close >= R1)then Taillevente = TaillePos/2 //sell Taillevente shares at market nextbaropen Condtradegratuit = 1 endif // Sortie au 30/06/2021 If longonMarket and Date >= DateArret then Sell at market nextbaropen endif // condition d'achat if CondAch and Not Onmarket then // Définition du StopLossini if Not OnMarket then StoplossIni = Close - 4*AverageTrueRange[20](Close) RiskIni = 4*AverageTrueRange[20](Close) if StopLossIni > Close*0.97 then StopLossIni = Close*0.97 RiskIni = Close*0.03 Endif If StopLossIni < Close*0.85 then StopLossIni = Close * 0.85 Endif Endif // Définition de la taille de position en un nombre pair TaillePos = 600/(Close -StopLossIni) TaillePos = Round(TaillePos-0.5) TaillePos = TaillePos - (TaillePos MOD 2) StopLoss = StopLossIni //Achat Buy TaillePos Shares at market nextbaropen CondTradeGratuit = 0 // fin de if CondAch and Not Onmarket endif