Bonjour à tous,
Comme me l’a conseillé Nicolas hier soir, j’ouvre aujourd’hui un nouveau sujet à propos d’un message d’erreur lorsque j’essaie de lancer un algorithme en réel. J’ai en réalité 2 algorithmes complémentaires qui doivent se synchroniser via un indicateur ProBuilder qui simule les prises de position du premier algortihme (code principal).
Voilà le message d’erreur affiché par ProOrder quelques secondes après que j’ai mis en marche mon code :
“Votre système de trading a été arrêté car au moins un indicateur utilisé manque d’historique pour être calculé. Merci d’augmenter la quantité d’historique pré-chargée au démarrage du système en utilisant l’instruction DEFPARAM (ex : DEFPARAM Preloadbars = 2000).”
Très bien, seulement dans mon code je n’appelle jamais plus de quelques barres d’historique (20 exactement pour l’HistoricVolatility dans le code ProBuilder) or, j’ai une ligne DEFPARAM PRELOADBARS = 1000 qui devrait être largement suffisante… De plus à l’affichage de ce message d’erreur j’ai bien évidemment essayer de modifier le nombre de barres à précharger (jusqu’à plusieurs milliers) mais cela n’a rien changé.
Je ne comprends pas ce qui pose problème surtout que je n’ai aucun problème en Backtest. Pourquoi ? Pour moi, de mon côté, tout fonctionne exactement comme je l’ai codé en BackTest sauf que je ne peux pas le lancer sur le marché.. Un peu frustrant (rire).
Si quelqu’un pouvait m’éclairer et me permettre de lancer cette stratégie cela serait génial!
Merci par avance pour votre temps passé sur nos questions qui parfois, faut il l’avouer, ne nécessitent qu’un peu de bon sens et d’observations.
PS : Je vous joins aussi l’indicateur ProBuilder que j’ai crée pour simuler le code principal bien qu’il ne soit surement pas d’un grand intérêt car, comme je l’ai déjà stipulé plus haut, il n’appelle pas plus de 20 d’historique. Mais tout est là. Encore merci pour votre aide.
// Defparam
DEFPARAM CumulateOrders = false
DEFPARAM PRELOADBARS = 1000
// Targets and stop
TPMain = 0.0006
SLMain = 50
TP = ((SLMain-0.5)-(10000*PendingLevel))
// Settings
PSize = 1
PendingLevel = 0.0025
LevelExit = 0.0005
// Indicator
myLong, myShort = CALL "Indicator"(close)
// If still on market after Main's exit
IF OnMarket THEN
// Main's long
IF ShortOnMarket AND (myLong = 0) AND (myLong[1] <> 0) THEN
EXITSHORT AT MARKET
ENDIF
// Main's short
IF LongOnMarket AND (myShort = 0) AND (myShort[1] <> 0) THEN
SELL AT MARKET
ENDIF
ENDIF
// Do not allow to take position after SLMain exit
IF NOT OnMarket AND OnMarket[1] THEN
IF ShortOnMarket[1] AND Low[1] < (x - (SLMain/10000)) THEN
ENDIF
IF LongOnMarket[1] AND High[1] > (y - (SLMain/10000)) THEN
ENDIF
ELSE
// Long
IF Not OnMarket AND (myLong <> 0) AND High < (myLong + TPMain) THEN
SELLSHORT PSize CONTRACTS AT (myLong - PendingLevel) Stop
x = myLong
ENDIF
// Short
IF Not OnMarket AND (myShort <> 0) AND Low > (myShort - TPMain) THEN
BUY PSize CONTRACTS AT (myShort + PendingLevel) Stop
y = myShort
ENDIF
IF OnMarket THEN
// Long closing
IF ShortOnMarket THEN
EXITSHORT AT (x - LevelExit) stop
// Long agressive sellshort
IF (High[1] < (x + TPMain)) THEN
SELLSHORT PSize CONTRACTS AT (myLong - PendingLevel) Stop
ENDIF
ENDIF
// // Short closing
IF LongOnMarket THEN
SELL AT (y + LevelExit) stop
// Short agressive buy
IF (Low[1] > (y - TPMain)) THEN
BUY PSize CONTRACTS AT (myShort + PendingLevel) Stop
ENDIF
ENDIF
ENDIF
ENDIF
// Set TP
SET TARGET pPROFIT TP
// Main's target and stop
TPMain = 0.0006
SLMain = 0.0050
// Settings
MyVolat = 0.08
Spread = 0.00003
SwitchOn = 095000
SwitchOff = 180000
// Indicators settings
ParabolicSAR = SAR[0.02,0.02,0.2]
MyVolatility20 = HistoricVolatility[20]
// Conditons to start
VolatilityConditions = (MyVolatility20[1] > MyVolat)
TradingTimes = Time > SwitchOff OR Time < SwitchOn
IF VolatilityConditions THEN
allows = 1
ELSE
allows = 0
ENDIF
IF (x <> 0) OR (y <> 0) THEN
// Long loop
IF (x <> 0) THEN
IF (High[1] > (x + TPMain + Spread)) THEN
x = 0
// Agressive opening
TradingTimes = Time > SwitchOff OR Time < SwitchOn
IF TradingTimes THEN
x = 0
y = 0
ELSE
IF allows THEN
// Long agressive opening
c1 = (ParabolicSAR[1] > High[1])
c2 = (High > (ParabolicSAR[1]-Spread))
IF c1 AND c2 THEN
x = ParabolicSAR[1]
ENDIF
// Short agressive opening
c3 = (ParabolicSAR[1] < Low[1])
c4 = (Low < (ParabolicSAR[1]+Spread))
IF c3 AND c4 THEN
y = ParabolicSAR[1]
ENDIF
ENDIF
ENDIF
ELSE
y = 0
ENDIF
ELSE
IF (High[1] > (y + SLMain)) THEN
x = 0
y = 0
ENDIF
ENDIF
// Short loop
IF (y <> 0) THEN
IF (Low[1] < (y - TPMain - Spread)) THEN
y = 0
// Agressive opening
TradingTimes = Time > SwitchOff OR Time < SwitchOn
IF TradingTimes THEN
x = 0
y = 0
ELSE
IF allows THEN
// Long agressive opening
c1 = (ParabolicSAR[1] > High[1])
c2 = (High > (ParabolicSAR[1]-Spread))
IF c1 AND c2 THEN
x = ParabolicSAR[1]
ENDIF
// Short agressive opening
c3 = (ParabolicSAR[1] < Low[1])
c4 = (Low < (ParabolicSAR[1]+Spread))
IF c3 AND c4 THEN
y = ParabolicSAR[1]
ENDIF
ENDIF
ENDIF
ELSE
x = 0
ENDIF
ELSE
IF (Low[1] < (x - SLMain)) THEN
x = 0
y = 0
ENDIF
ENDIF
ELSE
IF TradingTimes THEN
x = 0
y = 0
ELSE
IF allows THEN
// Long opening
c1 = (ParabolicSAR[1] > High[1])
c2 = (High > (ParabolicSAR[1]-Spread))
IF c1 AND c2 THEN
x = ParabolicSAR[1]
ENDIF
// Short opening
c3 = (ParabolicSAR[1] < Low[1])
c4 = (Low < (ParabolicSAR[1]+Spread))
IF c3 AND c4 THEN
y = ParabolicSAR[1]
ENDIF
ENDIF
ENDIF
ENDIF
RETURN x as "Long", y as "Short"