How to create memory to turn something on or off


New member
So say I have points 'a' and 'b' that occur on a chart. They can be a crossover arrow or something similar. And I'd like to turn something to '1' between 'a' and the next 'b' and '0' at all other times. a's and b's are not necessarily alternating. Is there a way to do this?

I can get 'a' to restart with a counter loop (ie. x = x+1 except at point a where it equals 0) but don't know how to stop at point 'b.' Does the Fold loop help here?



def cond_a = [some condition];
def cond_b = [some other condition];
def the_switch = if cond_a then 1 else if cond_b then 0 else the_switch[1];

Similar threads