Hi everyone,
starting out with the visual builder, awesome, especially the part of being able to see the Python code of the blocks that are build. Good for my learning curve.
Almost done making my first strategy with visual builder, however the part of Exits I do not get.
In my long direction trades, my stoplos level consist of a hard stoplos level right under the Low of the candle juat before the Entry candle…
The logic should be something like: IF Close < Low [Barsinceentry + 2].
Here barssince entry should then be a number that changes along when rhe trade has more barse, so the level +2 alwats matches with rhe Low of the bar before Entry.
Can anyone help me how I should make this with the Visual building blocks.
Thanks a lot and have a great day everyone,
Wouter ( new Blueshift enthusiast :))
Welcome to Blueshift! To place a stoploss with your logic, the steps are 1) record the price where you want to trigger the stop and 2) add a stoploss to your strategy (the last building block). See the image here. Here we picked up the buy and hold template. We record the stop trigger price right at our entry block - the price is the low with 1 period lag (i.e. the the low of 1 period before current bar at which we place the entry order). We store this in a variable called "entry". Then we use this variable to set out stoploss level - selecting a price based stoploss.
I think it you are right - it smells like trailing stoploss. In the code sample, the stoploss levels will be updated each time an entry condition is met (in this case the entry is time-based, every month start of the month). However, note: unlike true trailing stoploss though, it will not be updated continuously.
The way you are approaching the problem is to set the stoploss level at N lag from now at any time, where N keeps on increasing to refer to a fixed epoch in the past (the entry). The way I have approached is to identify that epoch in time directly, and set a variable at that point in time to capture that stoploss level. Then we can simply check our stoploss against that variable. Let me know if that makes sense (or correctly catpures what you are trying to do)?
Assuming it does, in the sample, that epoch is identified as each entry (at each entry we reset the stoplevel and store it in the variable "entry"). One alternative is to consider only the first entry (this will be a bit convoluted in the visual interface becuase of some trivial features we are yet to add to it). Is this what you are looking for?