```
##
input price = close;
input length1 = 8;
input length2 = 21;
input length3 = 200;
input displace = 0;
def A1 = ExpAverage(price[-displace], length1);
def A2 = ExpAverage(price[-displace], length2);
def A3 = ExpAverage(price[-displace], length3);
##
input factor = 1.5;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;
def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length2);
def average = MovingAverage(averageType, price, length2);
def middle_band = average[-displace];
def Upper_Band = average[-displace] + shift[-displace];
def Lower_Band = average[-displace] - shift[-displace];
##
def WAD = AccumDistBuyPr();
def ZeroLine = 0;
##
def Rayavg = ExpAverage(close, length2);
def BullPower = high - Rayavg;
def BearPower = low - Rayavg;
##
input fastLength = 13;
input slowLength = 21;
input MACDLength = 8;
input averageType2 = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
def Value = MovingAverage(averageType2, close, fastLength) - MovingAverage(averageType2, close, slowLength);
def Avg = MovingAverage(averageType2, Value, MACDLength);
def Diff = Value - Avg;
def Condition1 = if
middle_band > middle_band[1]
and
Lower_Band > Lower_Band[1]
then 1 else Double.NaN;
def Condition2 = if
WAD > WAD[1]
then 1 else Double.NaN;
def Condition3 = if
A1 > A2
then 1 else Double.NaN;
def Condition4 = if
BullPower > BullPower[1]
and
BearPower > BearPower[1]
then 1 else Double.NaN;
def Condition5 = if
Value > Avg
then 1 else Double.NaN;
def Condition6 = if
middle_band < middle_band[1]
and
Lower_Band < Lower_Band[1]
then 1 else Double.NaN;
def Condition7 = if
WAD < WAD[1]
then 1 else Double.NaN;
def Condition8 = if
A1 < A2
then 1 else Double.NaN;
def Condition9 = if
BullPower < BullPower[1]
and
BearPower < BearPower[1]
then 1 else Double.NaN;
def Condition10 = if
Value > Avg
then 1 else Double.NaN;
def sum1 = Condition1 + Condition2 + Condition4 + Condition5;
def trigger1 = if sum1 >= (2) then 1 else 0;
def sum2 = Condition6 + Condition7 + Condition9 + Condition10;
def trigger2 = if sum2 <= (2) then 1 else 0;
def Buy = Condition3 and trigger1;
plot a = Buy;
def Sell = Condition8 and trigger2;
plot b = Sell;
```