H/L 2\$ Candles indicator

kharbi

New member
VIP
Hello everyone... Can anyone, if possible, create an indicator that creates a signal or a line on the high and low on the chart, if the following conditions are met:

- If the length of one, two, or three candles is >= \$2.. (Note: the number of candles should not exceed 3).

Since I am currently doing a study based on that, after fulfilling the condition, I set Fibonacci and wait for prices to bounce back at 38%, 50%, or 61%, and then I enter according to the trend and my target is 100%. The results were fantastic (5 min spy).

Thank you all

Last edited by a moderator:
Solution
Hello everyone... Can anyone, if possible, create an indicator that creates a signal or a line on the high and low on the chart, if the following conditions are met:

- If the length of one, two, or three candles is >= \$2.. (Note: the number of candles should not exceed 3).

Since I am currently doing a study based on that, after fulfilling the condition, I set Fibonacci and wait for prices to bounce back at 38%, 50%, or 61%, and then I enter according to the trend and my target is 100%. The results were fantastic (5 min spy).

Thank you all

This plot the...

SleepyZ

Well-known member
VIP
Hello everyone... Can anyone, if possible, create an indicator that creates a signal or a line on the high and low on the chart, if the following conditions are met:

- If the length of one, two, or three candles is >= \$2.. (Note: the number of candles should not exceed 3).

Since I am currently doing a study based on that, after fulfilling the condition, I set Fibonacci and wait for prices to bounce back at 38%, 50%, or 61%, and then I enter according to the trend and my target is 100%. The results were fantastic (5 min spy).

Thank you all

This plot the high/low, price_bubbles and fibs. You can control at input count how many of these groups plot.

The image is of from your chart with the code below plotting the last 2 groupings (input count = 2)

[Edit: changed \$2 criteria from a hard code to an input diff
Also noticed that you have items checked on the left side under chart settings, price axis. It is best to uncheck these.

Ruby:
``````input count = 2;
input diff  = 2;
def r = (Highest(high, 3) - Lowest(low, 3));
def h = if r >= diff then Highest(high, 3) else h[1];
def l = if r >= diff then Lowest(low, 3) else l[1];
def hbar = if r >= diff then 1 else 0;
def lbar = if r >= diff then 1 else 0;

def dataCounth = CompoundValue(1, if hbar[1] == 0 and hbar then dataCounth[1] + 1 else dataCounth[1], 0);
plot hh = if HighestAll(dataCounth) - dataCounth <= count - 1 then h else Double.NaN;
hh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh.SetDefaultColor(Color.CYAN);

def dataCountl = CompoundValue(1, if lbar[1] == 0 and lbar then dataCountl[1] + 1 else dataCountl[1], 0);
plot ll = if HighestAll(dataCountl) - dataCountl <= count - 1 then l else Double.NaN;
ll.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll.SetDefaultColor(Color.CYAN);

input show_bubbles = yes;
input bubblemover_updown = 3;

AddChartBubble(show_bubbles and hbar[1] == 0 and hbar, hh + TickSize() * bubblemover_updown, hh, Color.WHITE);
AddChartBubble(show_bubbles and lbar[1] == 0 and lbar, ll - TickSize() * bubblemover_updown, ll, Color.WHITE, no);

plot fib1 = ll + (hh - ll) * .618;
plot fib2 = ll + (hh - ll) * .500;
plot fib3 = ll + (hh - ll) * .382;
fib1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fib2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fib3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fib1.SetDefaultColor(Color.WHITE);
fib2.SetDefaultColor(Color.YELLOW);
fib3.SetDefaultColor(Color.RED);``````

Last edited:

kharbi

New member
VIP
This plot the high/low, price_bubbles and fibs. You can control at input count how many of these groups plot.

The image is of from your chart with the code below plotting the last 2 groupings (input count = 2)

[Edit: changed \$2 criteria from a hard code to an input diff
Also noticed that you have items checked on the left side under chart settings, price axis. It is best to uncheck these.
You are amazing.. I will give it a try... Thank you very much

kharbi

New member
VIP
This plot the high/low, price_bubbles and fibs. You can control at input count how many of these groups plot.

The image is of from your chart with the code below plotting the last 2 groupings (input count = 2)

[Edit: changed \$2 criteria from a hard code to an input diff
Also noticed that you have items checked on the left side under chart settings, price axis. It is best to uncheck these.
After the first experience, the indicator works very well. But I found some problems and it is possible that it is my fault because I did not explain accurately ..

-I found overlap between trading sessions. Can each session be separated from the other? ? (as in picture No. 1)
-Is it possible to show the Fibonacci ratios in the case of ups and downs?
-One of the most important conditions of the study is that the two or three candles are of the same type, i.e. 3 green candles, i.e. its closing is higher than its opening, and vice versa with bearish candles. Which should be sequential .. (as in picture No. 2)

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?