Translation of Set stop ploss x ptrailing y
Forums › ProRealTime English forum › ProOrder support › Translation of Set stop ploss x ptrailing y
- This topic has 10 replies, 4 voices, and was last updated 3 years ago by
robertogozzi.
-
-
02/23/2021 at 2:42 PM #16244302/23/2021 at 3:30 PM #16244702/24/2021 at 6:31 PM #162540
Are you sure it would replace it ? This instruction is doing : “A stop loss is placed at x points from average position price and it becomes a trailing stop of y points if the trailing stop level becomes closer to current price than the stop loss level (this occurs price varies favourably by y points – x points)”
Because I wasn’t able to get the same results with a classic stop loss and a soft trailing stop code. I tried to do so before asking and failed.
Could you tell me what to do in the attached code, found in https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
please ? With x = 27 and y =5 for example.
Thanks you !
02/26/2021 at 9:13 AM #162666No, it will not do the same. The “set stop trailing” is a trailing stop attached to the order and handle by IG, not by the code, so it can move during a candle, while it is not the same with code read only once per bar.
If you want to use the trailing stop function from the blog, just add a “set stop loss” instruction to attach a stoploss to your orders before the trailing stop can start.
With this code, the trailing stop start when
trailingstart is >= 20 points
with a moving step of
trailingstep = 5
02/26/2021 at 10:53 AM #162671Ok thank you very much, I am indeed with IG. I understand that the code has to during a candle. I’ve done what you told me to do, but something goes wrong …under the “>=” function a red wave appears (impossible to run). Do you know why ?
1234567891011IF c3 AND c4 THENSELL AT MARKETENDIF// Stops et objectifsSet stop ploss 27//************************************************************************//trailing stop functiontrailingstart => 20 //trailing will start @trailinstart points profittrailingstep = 5 //trailing step to move the "stoploss"02/26/2021 at 1:10 PM #16268102/26/2021 at 1:48 PM #16268402/26/2021 at 2:07 PM #162686If you want to assign a value to a variable you can only use =.
If you want to test a logical condition you need to either assign it to a variable or use it with IF…ENDIF or WHILE…WEND.ProOrder wants to know what to do with TRAILINGSTART.
02/26/2021 at 4:24 PM #162688Right, thank you, I changed that and it seems to be accepted. Since, the result is not the same as with Stop ploss 27 ptrailing 5… 🙁
The IG spread is 2.5p on average here so I put it in both backtests, maybe this information could change the variables Nicolas told me to set ? (start : “=>22” and “step : 5”) ?
Thank you so much for your help.
02/26/2021 at 4:33 PM #162691If it works well… that’s fine, but I fear it won’t most of the times, because you assign variable a a logical value, 0 or 1, so the trailing will start after 0 or 1 pip at most…. which would lead, sooner or later, to not respecting the minimum distance for stop orders required by the broker.
Backtests may work, but when running on a demo account it is to be verified.
02/26/2021 at 4:36 PM #162692Nicolas suggested to use a value => 20, not to use “>=” as a relational operator!
-
AuthorPosts
Find exclusive trading pro-tools on
Thanks a lot