Tu peux essayer avec ce type de trailing stop (“IG style”) pour obtenir un tant soit peu le même fonctionnement que celui d’IG, attention toutefois, les niveaux de prix se recalculent uniquement une seule fois à chaque bougie :
StopLoss = 10 //StopLoss size
TrailingStopStart = 0 //Trailing Stop start at X points in profit
buystoploss = close-StopLoss*pointsize
sellstoploss = close+StopLoss*pointsize
if not onmarket then
ibuystoploss=buystoploss
isellstoploss=sellstoploss
endif
if longonmarket then
//checking and adjusting stoploss
if close-tradeprice>=trailingstopstart*pointsize then
ibuystoploss = max(ibuystoploss,high-(stoploss+trailingstopstart)*pointsize)
endif
//set the stoploss level
sell at ibuystoploss stop
endif
if shortonmarket then
//checking and adjusting stoploss
if tradeprice-close>=trailingstopstart*pointsize then
isellstoploss = min(isellstoploss,low+(stoploss+trailingstopstart)*pointsize)
endif
//set the stoploss level
exitshort at isellstoploss stop
endif
Pourquoi le coder en manuel ? Le code ne fonctionne pas Chez IG ?
Set stop ploss x ptrailing y
Est-ce qu’il serait possible de trouver une façon de coder en manuel le code suivant
En l’occurence x = 27 et y = 5. Il ne peut en effet pas “tourner” en réel. J’ai essayé à partir de ce qui a déjà été fourni dans d’autres topics pour reproduire le trailing stop, sans succès.
Merci beaucoup pour votre aide.