Support Board
Date/Time: Wed, 22 Jan 2025 23:26:13 +0000
[User Discussion] - How to use use IF/ELSE in a code?
View Count: 1121
[2018-10-30 19:03:52] |
David Clarke - Posts: 23 |
I’ve written this ‘crude’ (as in rough) code (for a Trading System Based on Alert Condition) to identify a pullback and it works (to a degree!) – AND(C>ID1.SG2,C>=C[-1],C<=C[-2]) But, ideally, I just want it to trigger just once, after a Moving Average crossover. I am lead to believe that using ‘IF/ELSE’ might enable that, but I just don't know where to start. Can you help, please? |
[2018-10-30 21:59:29] |
Sawtooth - Posts: 4159 |
You don't need to use the IF function when the result is boolean. Try this for a Buy Entry: =AND(CROSSFROMBELOW(C,ID1.SG2),C>=C[-1],C<=C[-2]) and this for a Sell Entry: =AND(CROSSFROMABOVE(C,ID1.SG2),C<=C[-1],C>=C[-2]) Here is the documentation for this study: Trading System Based on Alert Condition Here are some alert formula examples: Study/Chart Alerts And Scanning: Alert Formula Examples |
To post a message in this thread, you need to log in with your Sierra Chart account: