how to write a condition which only allows one position (long or short) at a time?

B

birdie123

New member
I struggle to write a condition which only allows one position at a time.

def buyCondition = if price > 100 then 1 else 0;
plot buyOrder = if buyCondition then price else Double.NaN;

This will plot multiple buy orders. I want to add a condition that once a buy order is generated, no more buy orders can be generated (only one position at a time). How can I do a condition looks like?

def buyCondition = if price > 100 and CONDITION to be written then 1 else 0;

Thanks in advance.
 

Similar threads

Top