Hi, I am trying to write a buy order where the "def buy =" meets some criteria but I also want to add Not true criteria.
Let me explaine better, I want the strategy to buy when the price bar opens above the fast and slow ema and closes below the fast and slow ema but the MACD histogram can only be dark green or bright red.
Here is part of the code:
For the macd:
def Value1 = MovingAverage(averageType1, close(period = Agg1), fastLength1) -
MovingAverage(averageType1, close(period = Agg1), slowLength1);
def Avg1 = MovingAverage(averageType1, Value1, MACDLength1);
def Diff1 = Value1 – Avg1;
def MACDAgg1 = if Diff1 >= 0
then if Diff1 > Diff1[1]
then PosUp
else PosDn
else if Diff1 < Diff1[1]
then NegDn
else NegUp;
def buy = open > slowema && close < slowema and open > fastema && close < Fastema and Macdagg1 == NegDn or PosDn;
and when I go to the charts, it wont work like I a imegine. maybe I should use another word instead of "or".
Can someone help me please!
Let me explaine better, I want the strategy to buy when the price bar opens above the fast and slow ema and closes below the fast and slow ema but the MACD histogram can only be dark green or bright red.
Here is part of the code:
For the macd:
def Value1 = MovingAverage(averageType1, close(period = Agg1), fastLength1) -
MovingAverage(averageType1, close(period = Agg1), slowLength1);
def Avg1 = MovingAverage(averageType1, Value1, MACDLength1);
def Diff1 = Value1 – Avg1;
def MACDAgg1 = if Diff1 >= 0
then if Diff1 > Diff1[1]
then PosUp
else PosDn
else if Diff1 < Diff1[1]
then NegDn
else NegUp;
def buy = open > slowema && close < slowema and open > fastema && close < Fastema and Macdagg1 == NegDn or PosDn;
and when I go to the charts, it wont work like I a imegine. maybe I should use another word instead of "or".
Can someone help me please!