Bonjour Frytconcord et bienvenue sur les forums de PRC, ayant des forums divisés par langues, puis par sous-thèmes, la coutume dans les forums PRC est de parler la langue du forum où on poste, merci de rester en Français sur le présent forum, et de réserver l’Anglais pour les forums PRC anglais.
Aussi, j’édite ton message pour mettre le listing du code au bon format, mais merci pour les prochains messages d’utiliser le bouton <> dans la barre d’outil de l’éditeur de messages pour insérer du code au format PRT.
Hello Frytconcord and welcome to the forums of PRC, having forums divided by languages, then by sub-topics, the custom in forums PRC is to speak the language of the forum where we post, thank you for staying in French on this forum, and reserve English for the English PRC forums.
Also, I’m editing your message to put the code listing in the correct format, but thanks for future messages to use the <> button on the message editor toolbar to insert code in PRT format.
@Frytconcord
Thank you for respecting some classic rules: posting in the right place and in the right language! This allows me and the moderators to focus on the answers rather than the household! 👿
Now, about your question, this ‘trailing stop’ function is not the “SET STOP TRAILING” instruction of the programming language, it simulates it, so it can be used in limited risk account with these limitations:
The minimum stop distances are greater than the “Expert” accounts (current normal account), the information of this distance can be found in the instrument’s manual trading information (expressed in points or percentage for shares). Since the trailing stop will not work, the SET STOP TRAILING instruction will be inoperative, so I advise you to use the coded trailing stop you find in the blog part of the site (many strategies already use it in the code library ). The stoploss can be far from the entry price, far enough, but you have to take into account your margin required to place it (of course you can not lose more than the size of your cash account, so be vigilant at level of the stoploss).
Oh! sorry I did not understand the forum. Sorry
“The minimum stop distances are greater than the “Expert” accounts (current normal account), the information of this distance can be found in the instrument’s manual trading information”
or find this information?
if I understand correctly it will work you who has it? I do not need to modify it for this:
Updated version of trailing SL
sorry, but do you the code trailing stop? I found a lot in the library all different ! Thank you
@Nicolas
“The minimum stop distances are greater than the “Expert” accounts (current normal account), the information of this distance can be found in the instrument’s manual trading information (expressed in points or percentage for shares). Since the trailing stop will not work, the SET STOP TRAILING instruction will be inoperative, so I advise you to use the coded trailing stop you find in the blog part of the site (many strategies already use it in the code library ). The stoploss can be far from the entry price, far enough, but you have to take into account your margin required to place it (of course you can not lose more than the size of your cash account, so be vigilant at level of the stoploss).”
Oh! sorry I did not understand the functioning of the forum. sorry
I find but I can not find any information. Or find this information?
If I understand correctly, I do not need to change the code?
Or should I add that:
Updated version of trailing SL
thanks for your understanding
defparam cumulateorders = false
//order launch (example) would be set to any other entry conditions
//c1 = close>close[1]
c2 = close<close[1]
//if c1 then
//BUY 1 LOT AT MARKET
//SET STOP PLOSS 50
//endif
if c2 then
SELLSHORT 1 LOT AT MARKET
SET STOP PLOSS 50
endif
//************************************************************************
//trailing stop function
trailingstart = 20 //trailing will start @trailinstart points profit
trailingstep = 5 //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
GRAPH newSL as "trailing"
I dot not have a limited risk account myself, but I believe that as long as your pending STOP orders is far enough than the current price (the required points distance from the Close), it should work.
thanks for your response nicolas. just a small question. the stop at 50 is far enough away for you? otherwise I use the trailing stop with parameters 9 and 10 see below
//trailing stop function
trailingstart = 9 //trailing will start @trailinstart points profit
trailingstep = 10 //trailing step to move the "stoploss"