Checking if Price is Too Far Away from a Modified Baseline
-
Hi all,
After many times of finding super helpful existing forums, I have finally come upon an problem that I haven't been able to figure out a solution based on other people's forum entries. So I greatly appreciate all the help!I am trying to have my algo avoid trades if the price is already farther away from my "baseline" indicator by 1.0ATR + Baseline (i.e. for a BUY trade, if the baseline is 1.300 and the ATR is 120, then if price is greater than 1.300 + 0.120 = 1.42 the algo will not take the trade). Unfortunately it doesn't seem to work! My goal was to create a variable that was equal to the previous candle close + the previous candle. Then it would check price compared to this variable and only proceed if price was within the 1.5ATR of the baseline.
Below is a link for my current algo. I apologize for how messy it is, the items are labeled "Calculation and Check for price within 1.5ATR" at the bottom of the page. Any advice as to why this isn't working would be very appreciated!
-
@craaiig No project is visible. You can try this:

This block is measuring the distance between current price and a MA baseline. Then it requires the distance to be higher or equal than current ATR multiplied by 1.5. Please remember this is for buys. In case of a sell you whould swap both price and MA positions on top of the block.
-
@l-andorrà
Thank you! I hadn't seen or used that function yet and it looks like it is working now. -
@craaiig You're welcome.