Yohannes24
New member
I have the following conditions I would like to add to this original code which is relatively simple :
I want to add the following conditions :
#This was the closest I got but the code does not signal for the SELL and LIQD conditions. Any aid in adding this to the code or fixing it below would be great. Thank you in advance.
input price = close;
input Length1 = 10;
input Length2 = 20;
input Length3 = 50;
input Length4 = 200;
input displace = 0;
input averageType = AverageType.SIMPLE;
plot Avg1 = MovingAverage(averageType, price[-displace], Length1);
plot Avg2 = MovingAverage(averageType, price[-displace], Length2);
plot Avg3 = MovingAverage(averageType, price[-displace], Length3);
plot Avg4 = MovingAverage(averageType, price[-displace], Length4);
Avg1.SetDefaultColor(GetColor(0));
Avg2.SetDefaultColor(GetColor(1));
Avg3.SetDefaultColor(GetColor(2));
Avg4.SetDefaultColor(GetColor(3));
# Condition One
def condition1 = Avg1 > Avg2 and Avg2 > Avg3;
def cross_above_avg4 = Crosses(Avg1, Avg4, CrossingDirection.ABOVE);
def cross_below_avg2 = Crosses(Avg1, Avg2, CrossingDirection.BELOW);
AddChartBubble(cross_above_avg4 and condition1, high, "LONG", Color.GREEN, no);
AddChartBubble(cross_below_avg2 and condition1, low, "SELL", Color.RED, yes);
# Condition Two
def condition2 = Avg1 < Avg2 and Avg2 < Avg3;
def cross_below_avg4 = Crosses(Avg1, Avg4, CrossingDirection.BELOW);
def cross_above_avg2 = Crosses(Avg1, Avg2, CrossingDirection.ABOVE);
AddChartBubble(cross_below_avg4 and condition2, high, "SHORT", Color.RED, yes);
AddChartBubble(cross_above_avg2 and condition2, low, "LIQD", Color.GREEN, no);
I want to add the following conditions :
#This was the closest I got but the code does not signal for the SELL and LIQD conditions. Any aid in adding this to the code or fixing it below would be great. Thank you in advance.
input price = close;
input Length1 = 10;
input Length2 = 20;
input Length3 = 50;
input Length4 = 200;
input displace = 0;
input averageType = AverageType.SIMPLE;
plot Avg1 = MovingAverage(averageType, price[-displace], Length1);
plot Avg2 = MovingAverage(averageType, price[-displace], Length2);
plot Avg3 = MovingAverage(averageType, price[-displace], Length3);
plot Avg4 = MovingAverage(averageType, price[-displace], Length4);
Avg1.SetDefaultColor(GetColor(0));
Avg2.SetDefaultColor(GetColor(1));
Avg3.SetDefaultColor(GetColor(2));
Avg4.SetDefaultColor(GetColor(3));
# Condition One
def condition1 = Avg1 > Avg2 and Avg2 > Avg3;
def cross_above_avg4 = Crosses(Avg1, Avg4, CrossingDirection.ABOVE);
def cross_below_avg2 = Crosses(Avg1, Avg2, CrossingDirection.BELOW);
AddChartBubble(cross_above_avg4 and condition1, high, "LONG", Color.GREEN, no);
AddChartBubble(cross_below_avg2 and condition1, low, "SELL", Color.RED, yes);
# Condition Two
def condition2 = Avg1 < Avg2 and Avg2 < Avg3;
def cross_below_avg4 = Crosses(Avg1, Avg4, CrossingDirection.BELOW);
def cross_above_avg2 = Crosses(Avg1, Avg2, CrossingDirection.ABOVE);
AddChartBubble(cross_below_avg4 and condition2, high, "SHORT", Color.RED, yes);
AddChartBubble(cross_above_avg2 and condition2, low, "LIQD", Color.GREEN, no);
Last edited: