'Storing crossover values for multi-crossover condition check Pine script
I'm developing a strategy that triggers signal after recording 4 crossovers of different lines.
The final variable I will use to trigger signals will be:
longSignal = ChikouAboveAll and priceAboveCloud and greenCloudSignal and tenkan_X_KijunLong
shortSignal = ChikouBelowAll and priceBelowCloud and redCloudSignal and tenkan_X_KijunShort
The problem is that those variables within carry the vale "true" when crossover function is true for each. Since the crosover boolean value is calculated separately for each bar the "longSignal" and "shortSignal" are true only when all crossover will happen on the same bar, which is quite rare.
How can I store the value for future bars for each crossover until it is being changed?
Thanks for all suggestions!
Solution 1:[1]
You could try doing a work around I use sometimes by redefining the cross to greater than. E.g. ChikouAboveAll = Chikou > All
Notice that instead of using a ta.crossover
you use >
Also, have you found another way around this already? Actually came here because this work around does not work for me anymore.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | luikronald |