• Get $40 off VIP by signing up for a free account! Sign Up

Help finishing my Indie

Williasmsmd19

New member
def sum1 = Condition1 + Condition2 + Condition4 + Condition5;
def trigger1 = if sum1 >= (4) then 1 else 0;

def sum2 = Condition6 + Condition7 + Condition9 + Condition10;
def trigger2 = if sum2 <= (1) then 1 else 0;

def Buy = condition3 and trigger1;
plot a = Buy;

def Sell = condition8 and trigger2;
plot b = Sell;



i would not call myself a professional programmer by any means, im more of a cut and paste programmer just picking up little things as a go, but iam stumped. This is simply not picking up target points and i can not find any examples to see where its gone wrong. If anyone is able to see what part of the end code is incomplete or able to point me in the direction of being able to fix it i would appreciate the help
 
iam stumped. This is simply not picking up target points and i can not find any examples to see where its gone wrong. If anyone is able to see what part of the end code is incomplete or able to point me in the direction of being able to fix it i would appreciate the help
Ruby:
##

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;
 
Last edited:
Code:
##

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;
# changed from <=  to  >=
def trigger2 = if sum2 >= (2) then 1 else 0;


def Buy = Condition3 and trigger1;
# modified
plot a = if Buy then low else Double.NaN;
# added the next 3 lines
a.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
a.SetLineWeight(1);
a.AssignValueColor(COLOR.CYAN);

def Sell = Condition8 and trigger2;
# modified
plot b = if Sell then high else Double.NaN;
# added the next 3 lines
b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
b.SetLineWeight(1);
b.AssignValueColor(COLOR.MAGENTA);
 
Code:
##

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;
# changed from <=  to  >=
def trigger2 = if sum2 >= (2) then 1 else 0;


def Buy = Condition3 and trigger1;
# modified
plot a = if Buy then low else Double.NaN;
# added the next 3 lines
a.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
a.SetLineWeight(1);
a.AssignValueColor(COLOR.CYAN);

def Sell = Condition8 and trigger2;
# modified
plot b = if Sell then high else Double.NaN;
# added the next 3 lines
b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
b.SetLineWeight(1);
b.AssignValueColor(COLOR.MAGENTA);
this is excellent, but it does not distinguish between one condition being present and all conditions being present. if i move the sum from 1- 4 i will receive the same results each time
 
Boolean Sum(add) Condition
Ruby:
##EMA

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);

##Keltner

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];

##WAD

def WAD = AccumDistBuyPr();
def ZeroLine = 0;

##Ray

def Rayavg = ExpAverage(close, length2);
def BullPower = high - Rayavg;
def BearPower = low - Rayavg;

##MACD

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 0;

##Buy Conditions

def Condition2 = if
WAD > WAD[1]
then 1 else 0;

def Condition3 = if
A1 > A2
then 1 else 0;

def Condition4 = if
BullPower > BullPower[1]
and
BearPower > BearPower[1]
then 1 else 0;

def Condition5 = if
Value > Avg
then 1 else 0;

##Sell Conditions

def Condition6 = if
middle_band < middle_band[1]
and
upper_Band < upper_Band[1]
then 1 else 0;

def Condition7 = if
WAD < WAD[1]
then 1 else 0;

def Condition8 = if
A1 < A2
then 1 else 0;

def Condition9 = if
BullPower < BullPower[1]
and
BearPower < BearPower[1]
then 1 else 0;

def Condition10 = if
Value > Avg
then 1 else 0;

def sum1 = Condition1 + Condition2 + Condition4 + Condition5;
def trigger1 = if sum1 >= (4) then 1 else 0;

def sum2 = Condition6 + Condition7 + Condition9 + Condition10;
# changed from <= to >=
def trigger2 = if sum2 >= (4) then 1 else 0;


def Buy = Condition3 and trigger1;
# modified
plot a = if Buy then low else Double.NaN;
# added the next 3 lines
a.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
a.SetLineWeight(1);
a.AssignValueColor(COLOR.CYAN);

def Sell = Condition8 and trigger2;
# modified
plot b = if Sell then high else Double.NaN;
# added the next 3 lines
b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
b.SetLineWeight(1);
b.AssignValueColor(COLOR.MAGENTA);
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
396 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top