Help with TOS code - Only One Signal at a Time


New member
OK, working on my first script and have a question. How do I set it up to only signal when something changes. Here is a simplified example:

def overprice = price > 10;
def underprice = price <10;
def a = if overprice then 1 else if underprice then 0 else double.nan;
def sell = a >=1;
def buy = a <=0;

I have arrows plotting for sell and buy. This works except it puts an arrow in for every candle above 10 and then again below 10. I want one arrow when it crosses above and one when it crosses below.

Again, this an extreme oversimplification of what I am doing but hopefully gets the point across.

Similar threads