How do I add a grace period?
-
If I for example had a 10 SMA and a MACD, I wanted to trade when the SMA crosses over from negative to positive but only if the MACD has crossed over from negative to positive in the last 5 candles.
How would I make this work? I basically want the MACD to cross over and then give a grace period of 5 candles in which the MACD block is allowed to be passed; as it stands right now it won't work because it wants the MACD and SMA to cross over at exactly the same time
-
Do this:

-
@l-andorrà Sorry for the late reply, I tried what you said but my bot doesn't seem to be trading still. Any ideas? https://fxdreema.com/shared/UbwBg2jpe
-
@l-andorrà So I looked it up (http://fxdreema.com/forum/topic/3449/CROSS-WIDTH-function-do-not-work/3) and it turns out the cross width isn't what I thought it was, it's not a grace period due; as FxDreema put it: "it's something useless I think. It compares 2 candles far away from each other and does not care of anything in between. All candles between 1 and 10 are just discarded."
Does anyone know how I can add a grace period any other way?
-
@zereleth You can always check the value of the MACD every single bar and compare it to as many previous bas as required. Not a nice way to do it but certainly efficient.
-
@l-andorrà Wouldn't that cause excessive bulk/slippage?
-
@zereleth Not at all. Storing the value of an indicator on several variables is not related to slippage. Just catch the value of MACD for the last 5 candles on 5 different variables. Compare them to each other and you will know for sure if there was a crosing or not within that period. Slippage is not relevant here because there is no open trade related.
-
@l-andorrà Sorry I think I might have used poor language, I don't mean slippage but i'm referring to a similar thing. Would having a bulkier setup not make the trades take longer to open as it has to run a larger script each tick? Also that answers my question about the MACD thank you i'll work on that
You're like my savoiur on this forum lmfao
-
@l-andorrà I tried this but it doesn't seem to be working or making any trades, i'd think trying to make a pass period would be a really common desire on this site but I can't find any other posts https://fxdreema.com/shared/VNIoiPzjc
-
@zereleth Specify candle ID 1 on all operans of all 'condition' blocks. Try it and let me know.