Trailing Stop - Variable as input
-
Is it possible to use a Variable as the initial trailing stop loss level?
I have used "Custom(level)", "Value", "Numeric" and inserted a Variable calculated in a Formula block as my initial trailing stop loss level. The block accepts it but when I run a test the trailing stop doesn't move. When I change it to Trailing stop is "Pips" and put in a value of say 80 the trailing stop moves as price moves.
-
A variable is just a name that have a number behind. There should be no difference if you use the value of 10 or a variable with value of 10. Make sure that the variable is numeric (double). What I don't understand is this initial trailing stop thing?
-
Thanks. That makes sense. There must be an error in my variable then. Is there a way to see the value of the variables? Does it matter if the variable is number of pips or an actual price? I assume as long as I specify within the block that I am setting the trailing stop based on pips or level that corresponds with the variable it should be ok?
By initial trailing stop I mean say I enter a long trade at 1.2250 with a stop loss set at 1.2200 and a trailing stop at 1.2150 then my initial trailing stop is 1.2150 and it is from this level that the stop trails behind price as price moves in my favour.
-
I think that "trailing stop" is the function, the whole procedure of moving SL while the price is moving. It's not just one particular level.
Variables can be seen of course, try "Comment" or "Trace"
-
I still can't get the trailing stop to run when using calculated variable. When changing to say an 80 pip stop loss the trailing stop works.
Any suggestions?
-
I have set up a very basis buy strategy with a trailing stop loss to see if I could get it to work as I think it should.
When I use a custom (level) the trailing stop is initiated but doesn't trail as price rises. https://fxdreema.com/shared/tv1d2Fcgc
When I use custom custom (price fraction) the trailing stop is initiated and does trail as price rises.
https://fxdreema.com/shared/Ww3EPLoPbI must be doing something wrong?
-
Here is how it works:
https://fxdreema.com/shared/EfwvTVxV
http://prntscr.com/cojx3eHere I dynamically change the level to be 100 pips below Candle Open. You can see where SL is changed and its exact prices. Note that those prices goes only in one direction
The value for Trailing Stop can be dynamic, but SL moves only in one direction, it doesn't work backwards. If let's say for some reason SL is higher than what is set in the Trailing Stop block, this SL will not be moved downwards, it will stay at it's level. In other words, if SL is too short, it is not touched.
-
Unfortunately I haven't figured out how to add the labels like you have to show the changes in the stop loss but hopefully the printscreen below will show what I mean.
When I use this EA using custom(price fraction) the stop loss moves up with price.
https://fxdreema.com/shared/yAIiKAhac
As can be seen here the stop loss moves up with price.
http://prntscr.com/cosxi1However when I use this EA using custom(level) the stop loss doesn't move with price.
https://fxdreema.com/shared/agTw2oRMd
As can be seen here.
http://prntscr.com/cosz3aIn neither of these EA's is a stop loss set. Only a trailing stop.
-
But your TrailStopLoss shows the value of 0.80739 and SL is obviously set at this price. Only if the value of the variable changes, only then SL would change. The idea of this option is to control SL from outside the block, but to use the block because of its one-direction function, to keep SL moving only upwards and never downwards.
About the labels - they should be text, just write whatever you want there. The variable must be below, in Value1, Value2 or whatever. Now you have empty text there.
-
Thanks again for your help. I still haven't figured out the labels but will keep playing with it to get it to work.
I thought that using custom (level) I was setting the initial level of the trailing stop and that it would then rise as price rises based on the trailing step being used. Similar to setting the pips value using custom (price fraction). Obviously this isn't the case.
I'll use the custom (price fraction) from now on.
-
Labels are text, write whatever you want to see on the chart. If a label have no text (which is by default), this row of information will not appear
If you want to set only the initial price, do that directly into Buy/Sell blocks, you will find custom (level) there as well. Then use whatever technique in Trailing stop to move it.