I'm trying to code short and cover signals based on a break of the Pre-market Lows, basically short when a candle closes below PM low and cover when a candle closes above the 9 EMA.
I'm having trouble writing a script that only triggers the Cover signal when a Short signal has been "true" in the last "x" amount of bars. For example, I'd have a Short signal, then a Cover signal, but then another Cover signal right after without there being a Short signal. I'm basically trying to say that once there is a Short Signal, I'm in an active position, and I can only Cover when there's an active position.
Can anyone help me out? I'm thinking I need to use fold, but I can't seem to figure it out.
Here's what I'm working with right now:
def sc1 = close < PMLow;
def sc2 = close[1] >= PMLow;
def short = sc1 and sc2;
def cc1 = open[1] < PMLow;
def cc1 = close > ema
or close > high[1]
or close > PMLow
or SecondsTillTime(1550) == 0;
def cover = cc1 and cc2;
The problem is my cc1 condition. The Cover triggers for the first Short, but then it would immediately Cover again if Price is waaaay below the PM Low.
I'm having trouble writing a script that only triggers the Cover signal when a Short signal has been "true" in the last "x" amount of bars. For example, I'd have a Short signal, then a Cover signal, but then another Cover signal right after without there being a Short signal. I'm basically trying to say that once there is a Short Signal, I'm in an active position, and I can only Cover when there's an active position.
Can anyone help me out? I'm thinking I need to use fold, but I can't seem to figure it out.
Here's what I'm working with right now:
def sc1 = close < PMLow;
def sc2 = close[1] >= PMLow;
def short = sc1 and sc2;
def cc1 = open[1] < PMLow;
def cc1 = close > ema
or close > high[1]
or close > PMLow
or SecondsTillTime(1550) == 0;
def cover = cc1 and cc2;
The problem is my cc1 condition. The Cover triggers for the first Short, but then it would immediately Cover again if Price is waaaay below the PM Low.
Last edited: