How to combine multiple Candle Stick scripts into one

dxk

Member
I created 3 candle stick patterns I am scanning for and I would like to combine them into one script
but there is a conflict because all the scripts are the same (strange I thought they would be different)

I copied and tested each individual candle script to make sure they are supposed to be different
not sure what is up with them being the same

I also tried assigning them numbers but that was a conflict

here are the images of each images labeled to each section of included code

Can you not combine patterns into one script?


BearBearBull
PFqivhj.jpg



BearBullBull
FbTe8u7.jpg


BullBearBull
VKB5zez.jpg




Code:
# BearBearBull

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    IsDown[2] and
    IsDown[1] and
    IsUp[0];

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PatternPlot.SetDefaultColor(GetColor(1));


# BearBullBull

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    IsDown[2] and
    IsUp[1] and
    IsUp[0];

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PatternPlot.SetDefaultColor(CreateColor(0, 102, 255));




# BullBearBull

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    IsUp[2] and
    IsDown[1] and
    IsUp[0];

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PatternPlot.SetDefaultColor(GetColor(4));
 

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

@dxk Are you sure you changed them? I did it and there's no conflict anymore.
I did but I then get this
Identifier Already Used: avgRange at 20:5
Identifier Already Used: avgRange at 35:5
Already assigned: avgRange at 20:5
Already assigned: avgRange at 35:5
Identifier Already Used: avgRange at 20:5
Identifier Already Used: avgRange at 35:5
Already assigned: avgRange at 20:5
Already assigned: avgRange at 35:5
Code:
# BearBearBull

def BearBearBullIsUp = close > open;
def BearBearBullIsDown = close < open;
def BearBearBullIIsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    BearBearBullIsDown[2] and
    BearBearBullIsDown[1] and
    BearBearBullIsUp[0];

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PatternPlot.SetDefaultColor(GetColor(1));

# BearBullBull

def BearBullBullIsUp = close > open;
def BearBullBullIsDown = close < open;
def BearBullBullIsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot2 =
    BearBullBullIsDown[2] and
    BearBullBullIsUp[1] and
    BearBullBullIsUp[0];

PatternPlot2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PatternPlot2.SetDefaultColor(CreateColor(0, 102, 255));


# BullBearBull

def BullBearBullIsUp = close > open;
def BullBearBullIsDown = close < open;
def BullBearBullIsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot3 =
    BullBearBullIsUp[2] and
    BullBearBullIsDown[1] and
    BullBearBullIsUp[0];

PatternPlot3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PatternPlot3.SetDefaultColor(GetColor(4));
 
It's strange that each script is the same for each candle pattern but they all plot a different candle pattern if I scan them one at a time
 
@dxk avgrange is still def 3 times. Remove 2 of them.
then I will be scanning for only one candle pattern, I have 3 candle patterns
I copied the script for 3 different candle patterns

so I should remove 3 avgrange, when I did that "Exactly one plot expected" and it won't let me ok it
 
@dxk If you're using this for a scanner then it should be 1 plot per scanner. When you def something, it for the whole script not just that section of code. Also, avgrange isn't used at all in the script so you can remove it altogether if you want.
 
  • Like
Reactions: dxk
Oh, it works fine one at a time the scan finds each candle pattern as designed

I was hoping to combine them to only one scan vs 3 scans

Is that possible?
 
@dxk Are you looking for any one of the 3 patterns? If you are then try this code. Seems extremely broad for a scanner so I hope you have other criteria.
Code:
# BearBearBull

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    (IsDown[2] and
    IsDown[1] and
    IsUp[0])
    or (IsDown[2] and
    IsUp[1] and
    IsUp[0])
    or (IsUp[2] and
    IsDown[1] and
    IsUp[0]);
 
  • Like
Reactions: dxk
@dxk Are you looking for any one of the 3 patterns? If you are then try this code. Seems extremely broad for a scanner so I hope you have other criteria.
Code:
# BearBearBull

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    (IsDown[2] and
    IsDown[1] and
    IsUp[0])
    or (IsDown[2] and
    IsUp[1] and
    IsUp[0])
    or (IsUp[2] and
    IsDown[1] and
    IsUp[0]);
thanks much that worked I'm getting all 3 candle patterns showing in the scans

I looked at the scripts closer its' the different combo of up's and downs grouped in ( ) with or
again thanks

On the yearly time frame it narrows it down a lot along with price brackets
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
209 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