Plot only for pairs of inside and outside bars


Category:
0
0

Hey Pete!  Hopefully, you’ve not answered this question before.  What I’m trying to make is an indicator that shows an arrow under the candle for when a two-bar pattern occurs.  I’m basically looking for an inside bar and outside bar.  My kicker is that I want them to appear next to each other.    I can get the candles to appear just not only when they are side by side.

–inside bar

def lo = low;
def hi = high;
def vo = volume;

def s = if hi[1] >= hi and lo[1] <= low then 1 else 0;
plot did = s;
did.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
did.SetLineWeight(3);
did.AssignValueColor(Color.WHITE);

 

–outside bar

def lo = low;
def hi = high;
def vo = volume;

def s = if high > high[1] and low < low[1] then 1 else 0;
plot did ;
did.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
did.SetLineWeight(3);
did.AssignValueColor(Color.LIGHT_ORANGE);
did = s;

 

 

Attachments:
Marked as spam
Posted by (Questions: 10, Answers: 15)
Asked on September 26, 2020 6:14 am
77 views
0
Private answer

Once I understand the request I will update the title of your question because "Two bar indicator" tells me nothing. After reading your description I see you mention inside and outside bars and something about wanting to find them side by side. But you did not specify in what order. Outside bar followed by inside bar or inside bar followed by outside bar. Or either one so long as any inside bar is next to any outside bar.

Your screenshot seems to hint that you would like to mark candles only when an outside bar is followed by an inside bar. That is the pattern you circled on your screenshot. But having to piece together bits and pieces of what you are requesting makes for a very confusing post.

So please state the request in perfectly clear terms so that I understand exactly what solution to provide.

Edit: In the comments section below we have clarification about what is being requested. The code is intended to mark outside bars with orange arrow and inside bars with white arrow but only when there is a pair of inside and outside bars together. (in any order)

Pretty sure this will fit that description:

def insideBar = high < high[1] and low > low[1];
def outsideBar = high > high[1] and low < low[1];
def pattern = insideBar and outsideBar[1] or outsideBar and insideBar[1];
plot signal = pattern or pattern[-1];
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signal.AssignValueColor(if outsideBar then Color.LIGHT_ORANGE else Color.WHITE);

There is absolutely no need to create variable names for the high and low before using them in your patterns. That is just a waste of space, time and effort. It is also very poor form to use signal characters for variable names. You should never use variable names such as "s". Spell out the variable names using camelCase. The code will be much easier to read and maintain.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 26, 2020 8:56 am
0
Hey Pete! Sorry, my screenshot was just indicating the only scenario I want to look for., as you see I circled that scenario but my indicators just appear on all the bars not only where those bars are side by side I don't care about the order I just want them to be side by side, so it could be an outside bar followed by an inside bar or an inside bar followed by outside bar.
( at September 26, 2020 10:16 am)
0
I have updated my answer to include my own solution.
( at September 26, 2020 11:13 am)
0
TY!!!
( at September 26, 2020 12:09 pm)