J’aimerais savoir s’il est possible de placer un ordre stop à l’aide d’une stratégie automatique.
Par exemple, en utilisant l’indicateur Reversal Point :
https://www.prorealcode.com/prorealtime-indicators/reversal-point-indicator/
- Si un Signa Reversal achat est détecté (Reversal croise à la hausse valeur 0.5).
Placer un ordre stop sur le bougie du signal x points au dessus du plus haut de la bougie.
- L’ordre stop reste valable 3 bougies. S’il n’est pas exécuté, il est supprimé.
et même process à la vente..
Ce type d’ordre est faisable ?
Le code ci-dessous doit remplir cet office. J’ai introduit la variable “distance” pour paramétrer l’écart entre la bougie du signal et le placement de l’ordre conditionnel STOP.
Il faudrait bien entendu ajuster les takeprofit et stoploss à convenance en fonction de l’instrument et du timeframe que l’on souhaite trader.
Defparam Cumulateorders=false
Distance = 10 //x points above or below the signal candle to place the pending stop order
// LONG
//Red/Green candle (reversal)
//Bullish candle close above the open of the previous red candle
//Space to the left (the low of the last 3 candles lower than the low of the last 50 candles)
//default stochastic (8,3,3) was in the oversold area within the last 3 candles
sto = stochastic[8,3]
c1 = close[1]<open[1] and close>open
c2 = close>open[1]
c3 = lowest[3](low)<lowest[50](low)[1] or lowest[3](low)<lowest[50](low)[2] or lowest[3](low)<lowest[50](low)[3]
c4 = summation[3](sto<20)>0
long = c1 and c2 and c3 and c4
if long then
longlevel=high
mybar = barindex
endif
if long and not longonmarket and barindex-mybar<=3 then
buy 1 contract at longlevel+Distance*pointsize STOP
endif
// SHORT
//Green/Red candle (reversal)
//Bearish candle close below the close of the previous green candle
//Space to the left (the high of the last 3 candles higher than the high of the last 50 candles)
//default stochastic (8,3,3) was in the overbought area within the last 3 candles.
c5 = close[1]>open[1] and close<open
c6 = close<open[1]
c7 = highest[3](high)>highest[50](high)[1] or highest[3](high)>highest[50](high)[2] or highest[3](high)>highest[50](high)[3]
c8 = summation[3](sto>80)>0
short = c5 and c6 and c7 and c8
if short then
shortlevel=low
mybar = barindex
endif
if short and not shortonmarket and barindex-mybar<=3 then
sellshort 1 contract at shortlevel-distance*pointsize STOP
endif
set target pprofit 30
set stop ploss 60
Tient nous au courant de tes tests ! Merci.