Vis à vis de ton dernier point, que penses-tu de récupérer plutôt les flux tick-by-tick (ceux de ib par exemple) afin de mieux anticiper la volatilité ?
Compliqué techniquement ? Risque de "manquer" des ticks dans la récupération en live ?
Code : #
//---parameters
MaxDailyLoss=c //Max daily loss allowed (in money)
// first time we launch the code, the trading is allowed
once TradeAllowed=1
// reset the current state of the strateygprofit each new day
If intradaybarindex=0 then
MyProfit=STRATEGYPROFIT
TradeAllowed=1
endif
// test if the strategyprofit of the day is currently below the daily loss allowed
If Strategyprofit<=MyProfit-MaxDailyLoss then
TradeAllowed=0
endif
...
if TradeAllowed=1 and conditionsachat then
buy
endif
Code : #
// --- Paramètres ---
maxDailyLoss = 200 // Perte max journalière
initialSize = 1 // Taille de base
profitStep = 500 // Gain requis pour +1 taille
maxSize = 10 // Taille max autorisée
// --- Variables internes ---
defparam cumulateorders = false
if day <> day[1] then
dailyLoss = 0
tradedToday = 0
endif
// Mise à jour perte journalière (si trade clôturé et en perte)
if positionperf(1) < 0 then
dailyLoss = dailyLoss + positionperf(1)
endif
// Autorisation de trader ?
canTrade = (dailyLoss > -maxDailyLoss)
// Calcul de la taille linéaire
currentProfit = StrategyProfit
size = initialSize + floor(currentProfit / profitStep)
if size < 1 then
size = 1
endif
if size > maxSize then
size = maxSize
endif
// Exemple d’entrée (à adapter à ta stratégie)
if canTrade and tradedToday = 0 and close > average[20](close) then
buy size contract at market
tradedToday = 1
endif
// Exemple de sortie (à adapter aussi)
if positionprofit > 100 or positionprofit < -50 then
sell at market
endif