mourningwood4521
Member
I want when:
When I string these together as individuals,
I have my 2 lines which follow their rules. when I input this:
It's not working and the line isn't going to zero when both of the conditions are not met.
Here is the script I have so far for the current one I'm having issues with. I'm including everything with the # and I've deleted a lot that wasn't working.
Another study I made that is completely unrelated to this one is the following using what I believe is the same format because I tried to copy it.
And this study works perfectly fine on the chart and the version I converted to a scan inquiry is flawless.
the # on the lines leading to the bottom is me showing my work on how I got there.
So, Im pretty confused why I can't combine the terms I want at the top on the script I am currently working with.
for my line/dataprofile to show a 1 when all these conditions are met and show a 0 if only one or any combination of these is not met.ADX[1] > ADX:
& RSI < 50;
& RSI[1] > 50;
&PPO > PPO[1];
&PPOEMA > PPOEMA[1];
& PPO > PPOEMA;
When I string these together as individuals,
Code:
def rsi_1 = RSI < Trendline;
def rsi_2 = RSI[1] > Trendline;
plot Condition_RSI_1 = RSI_1;
plot Condition_RSI_2 = RSI_2;
I have my 2 lines which follow their rules. when I input this:
Code:
def RSI_3 = if(rsi_1 + rsi_2) then 1 else 0 and if (RSI > Trendline or RSI[1] < Trendline) then 0 else 1;
plot Condition_RSI_3 = RSI_3;
It's not working and the line isn't going to zero when both of the conditions are not met.
Here is the script I have so far for the current one I'm having issues with. I'm including everything with the # and I've deleted a lot that wasn't working.
Code:
declare lower;
#ADX
input length_ADX = 5;
input averageType_ADX = AverageType.WILDERS;
def ADX = DMI(length_ADX, averageType_ADX).ADX;
#-------------------------------------------------------------------------
#ppo and signal line
input fastPeriod = 6;
input slowPeriod = 15;
input signalPeriod = 9;
input price_1 = close;
def fastEma = ExpAverage( price_1, fastPeriod );
def slowEma = ExpAverage( price_1, slowPeriod );
def periodOK = fastPeriod < slowPeriod;
AddLabel( !periodOK, "ERROR: fastPeriod MUST be less than slowPeriod" );
def ppo = if periodOK then ((fastEma - slowEma) / slowEma) * 100 else 0;
def _signal = ExpAverage( ppo, signalPeriod );
#----------------------
def PpoEma = _signal;
def zeroLine = 0;
#----------------------------------------------------------------------------------
#RSI
input length = 5;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
input trendline = 50;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;
#def UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
#def DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;
#----------------------------------------------------------------------------------
def Adx_1 = ADX < ADX[1];
#def ADX_11 = ADX > ADX[1];
def rsi_1 = RSI < Trendline;
#def RSI_11 = RSI > Trendline;
def rsi_2 = RSI[1] > Trendline;
#def RSI_21 = RSI[1] < Trendline;
#def RSI_3 = if(RSI < Trendline + RSI[1] > Trendline) then 1 else 0 and if (RSI > Trendline or RSI[1] < Trendline) then 0 else 1;
def RSI_3 = if(rsi_1 + rsi_2) then 1 else 0 and if (RSI > Trendline or RSI[1] < Trendline) then 0 else 1;
def PPO_1 = ppo < ppo[1];
#def PPO_11 = ppo > ppo[1];
# and if(ppo > ppo[1]) then 0 else 1 and if(PpoEma < PpoEma[1]) then 0 else 1 and if(ppo > PpoEma) then 0 else 1 and if(ppo > ppo[1] + PpoEma < PpoEma[1]) then 0 else 1 and if(ppo > ppo[1] + ppo > PpoEma) then 0 else 1 and if(PpoEma < PpoEma[1] + ppo < PpoEma) then 0 else 1;
def PPO_2 = PpoEma > PpoEma[1];
#def PPO_22 = PpoEma < PpoEma[1];
def PPO_3 = ppo > PpoEma;
#def PPO_33 = ppo < PpoEma;
def PPO_4 = if (PPO_1 + PPO_2 + PPO_3) then 1 else 0;# and if (PPO_11 or PPO_22 or PPO_33) then 0 else 1;
#plot dataprofile_RSI= if (ADX_1 + RSI_1) then 1 else 0 and if (ADX_1 or RSI_1) then 0 else 1;
##plot dataprofile_ADX_RSI = if(ADX_1 + RSI_3) then 1 else 0 and if(ADX_1 or RSI_3) then 0 else 1;
#plot dataprofile = if(ADX_1;
#Plot dataprofile_2 = RSI_3;
#plot dataprofile_3 = PPO_1 + PPO_2 + PPO_3;
#plot dataprofile_3 = PPO_4;
#plot dataprofile_4 = if(dataprofile + dataprofile_2 + dataprofile_3) then 1 else 0;
#plot condition_PPO_3 = if (ppo > PpoEma) then 1 else if (PpoEma > ppo) then 0 else 1;
#plot condition_PPO_2 = if (PpoEma > PpoEma[1]) then 1 else 0 and if (PpoEma[1] > PpoEma) then 0 else 1;
#plot condition_PPO_1 = if (ppo < ppo[1]) then 1 else 0 and if (ppo[1] > ppo) then 0 else 1;
#def dataprofile_PPO_1 = condition_PPO_1;
#def dataprofile_PPO_2 = condition_PPO_2;
#def dataprofile_PPO_3 = condition_PPO_3;
#plot dataProfile_PPO = if (dataprofile_PPO_1 + dataprofile_PPO_2 + dataprofile_PPO_3) then 1 else 0 and if (dataprofile_PPO_1 or dataprofile_PPO_2 or dataprofile_PPO_3) then 0 else double.NaN and if(dataprofile_PPO_1 + dataprofile_PPO_2) then 0 else double.NaN and if(dataprofile_PPO_1 + dataprofile_PPO_3) then 0 else double.NaN and if(dataprofile_PPO_1 + dataprofile_PPO_3) or dataprofile_PPO_1 or dataprofile_PPO_2 or dataprofile_PPO_3 then 0 else double.NaN;
#plot dataProfile_PPO = dataprofile_PPO_1 + dataprofile_PPO_2 + dataprofile_PPO_3;
#plot dataprofile_
#---------
plot Condition_RSI_1 = RSI_1;
plot Condition_RSI_2 = RSI_2;
plot Condition_RSI_3 = RSI_3;
Another study I made that is completely unrelated to this one is the following using what I believe is the same format because I tried to copy it.
And this study works perfectly fine on the chart and the version I converted to a scan inquiry is flawless.
Code:
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.EXPONENTIAL;
#input showBreakoutSignals = no;
def Diff = MACD(fastLength, slowLength, MACDLength, averageTypeMACD).Diff;
#plot UpSignal = if Diff crosses above 0 then 0 else Double.NaN;
#plot DownSignal = if Diff crosses below 0 then 0 else Double.NaN;
input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeStoch = AverageType.SIMPLE;
#input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};
def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullK;
def SlowD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullD;
#plot DataProfile = (slowK[1] < slowD[1]) and (slowK > SlowD);
#plot DataProfile = (slowK[1] < slowD[1]) and (slowK > SlowD) and (lowest(SlowK[1], 3) < 50);
#plot DataProfile = (slowK[1] < slowD[1]) and (slowK > SlowD) and (lowest(SlowK[1], 3) < 70) and (Diff[1] < Diff);
#plot chart = if((slowK[1] < slowD[1]) and (slowK > SlowD) and (lowest(SlowK[1], 3) < 50) and (Diff[1] < Diff)) then 1 else 0;
def MACD = (Diff[1] < Diff);
def Stoch_Slow = (SlowK[1] < SlowD[1]) and (SlowK > SlowD);
def Stoch_Slow_1 = (lowest(SlowK[1], 3) < SlowK);
def Stoch_Slow_2 = slowK > slowD;
#def Stoch_Slow_2 = highest(SlowK[2]) > slowK;
#plot dataprofile = if(MACD + Stoch_Slow) then 1 else 0 and if(MACD or stoch_Slow)then 0 else 1;
plot dataprofile = if(MACD + Stoch_Slow + Stoch_Slow_1 + Stoch_Slow_2) then 1 else 0 and if(MACD or stoch_Slow or Stoch_Slow_1 or Stoch_Slow_2)then 0 else 1;
the # on the lines leading to the bottom is me showing my work on how I got there.
So, Im pretty confused why I can't combine the terms I want at the top on the script I am currently working with.