Intrinsic Knowledge
Member
Hello folks,
Just a quick question, as per below scripts:
As below "Test" scripts, my intention is when condition one (1) both BB_signal and RSI_signal is toggle "Yes",
condition two (2) is BB_signal toggle "Yes" and RSI_signal toggle "NO"
and condition three (3) is BB_signal toggle "NO" and RSI_signal toggle "Yes".
But when I toggle either one of BB_signal or RSI_signal to "NO", the whole signal disappear. Does anyone know what have I done wrongly? Much appreciated your advices.
Hope I have explained clearly. Cheers
### Test
def bear_signal = if (BB_downArrow and RSI_downArrow) then high else if BB_downArrow then high else if RSI_downArrow then high else double.nan;
plot Bearish_signal = bear_signal;
Bearish_signal.SetPaintingStrategy(PaintingStrategy.arrow_down);
Bearish_signal.SetDefaultColor(Color.orange);
Just a quick question, as per below scripts:
As below "Test" scripts, my intention is when condition one (1) both BB_signal and RSI_signal is toggle "Yes",
condition two (2) is BB_signal toggle "Yes" and RSI_signal toggle "NO"
and condition three (3) is BB_signal toggle "NO" and RSI_signal toggle "Yes".
But when I toggle either one of BB_signal or RSI_signal to "NO", the whole signal disappear. Does anyone know what have I done wrongly? Much appreciated your advices.
Hope I have explained clearly. Cheers
### Test
def bear_signal = if (BB_downArrow and RSI_downArrow) then high else if BB_downArrow then high else if RSI_downArrow then high else double.nan;
plot Bearish_signal = bear_signal;
Bearish_signal.SetPaintingStrategy(PaintingStrategy.arrow_down);
Bearish_signal.SetDefaultColor(Color.orange);
Code:
### One (1) BollingerBands
input BB_signal = yes;
def price = close;
input displace = 0;
input BB_length = 20;
input Num_Dev_Num = 2;
def Num_Dev_Dn = -Num_Dev_Num;
def Num_Dev_up = Num_Dev_Num;
def BB_averageType = AverageType.Simple;
def offset = sqrt ((high - low)) * 0.2;
def sDev = stdev(data = price[-displace], length = BB_length);
plot MidLine = MovingAverage(BB_averageType, data = price[-displace], length = BB_length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
def BB_bear_signal = if BB_signal and high > upperBand then 1 else double.nan;
def BB_downArrow = BB_bear_signal;
#BB_downArrow.SetPaintingStrategy(PaintingStrategy.arrow_down);
#BB_downArrow.SetDefaultColor(Color.orange);
def BB_bull_signal = if BB_signal and low < LowerBand then 1 else double.nan;
def BB_upArrow = BB_bull_signal;
#BB_upArrow.SetPaintingStrategy(PaintingStrategy.arrow_up);
#BB_upArrow.SetDefaultColor(Color.light_green);
### Two (2) RSI
input RSI_signal = yes;
input RSI_length = 14;
input over_Bought = 80;
input over_Sold = 20;
#input price = close;
def RSI_averageType = AverageType.WILDERS;
#input showBreakoutSignals = no;
def NetChgAvg = MovingAverage(RSI_averageType, price - price[1], RSI_length);
def TotChgAvg = MovingAverage(RSI_averageType, AbsValue(price - price[1]), RSI_length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def RSI_bear_signal = if RSI_signal and RSI > Over_Bought then 1 else Double.NaN;
plot RSI_downArrow = RSI_bear_signal;
#RSI_downArrow.SetPaintingStrategy(PaintingStrategy.arrow_down);
#RSI_downArrow.SetDefaultColor(Color.orange);
def RSI_bull_signal = if RSI_signal and RSI < Over_Sold then 1 else Double.NaN;
plot RSI_upArrow = RSI_bull_signal;
#RSI_upArrow.SetPaintingStrategy(PaintingStrategy.arrow_up);
#RSI_upArrow.SetDefaultColor(Color.light_green);
### Test
def bear_signal = if (BB_downArrow and RSI_downArrow) then high else if BB_downArrow then high else if RSI_downArrow then high else double.nan;
plot Bearish_signal = bear_signal;
Bearish_signal.SetPaintingStrategy(PaintingStrategy.arrow_down);
Bearish_signal.SetDefaultColor(Color.orange);
Last edited: