X-Axis Counting On Charts

Well-known member
I'm still working on a improved version of fractal energy, does anybody know how to make time a usable variable? Let me explain.

(reference picture to understand) Lets say I wanted to count the number of hours the upper resistance(upper blue line) has been unbroken. So for each hour starting after the candle that the red arrow is on it would be +1 in value, if the resistance was still a resistance 10 hours later, then the variable would have a value of 10 and so on. Is this possible, I'm sure it is I just can't figure it out. Having time under resistance as a variable should be extremely valuable. Right now the fractal formula doesn't include time, but only the difference between the highs and lows of a certain period. @mashume @diazlaz @Welkin @BenTen

Oh hey @YungTraderFromMontana I have been gone for awhile but I made that overnight volume you requested in the group message. Anyway 1 way of counting the number of periods where the upper resistance remains unbroken would just be a counter or Recursion rec() line...
That might eat up a lot of resources but something like this?
Code:
``def UnbrokenResistance = CompoundValue(1, if Price<Resistance then  UnbrokenResistance[1] + 1 else UnbrokenResistance[1], 0);``

Something along this line should keep a running total... Do you want the count to reset after so long outside of resistance or anything like that

Thanks, the compound value function is what I was looking for. I was able to figure out the volume also. How can I get it to reset when resistance is broken?

I got it, I just added an else if statement.

@MattATM do you know any methods of converting the value of variables to constants so you can use them as lengths? That's the new issue I have

@MattATM Yo would you be up for a call? I need someone with good thinkscript knowledge to help me out so I can blow by roadblocks I'm having in my code. If you're up for it text me and we can get a time to call. It would be a big help.

Last edited by a moderator:
do you know any methods of converting the value of variables to constants so you can use them as lengths? That's the new issue I have
@YungTraderFromMontana it seems that Thinkscript doesn't support using variables as lengths when it is expecting constants... However, you might perhaps work around this by keeping a running total that resets itself when something happens...
Like what you want but turned inside out...
So instead of saying TimeLength=(hours spent above a resistance) and then using that Length to calculate something; you might keep a running total.
Code:
``````Is the hour above the resistance line Yes?/No?
If No reset count or start other count...``````

I found a workaround. Can you see what I posted in the group earlier though, its really the last issue I need to solve before I have a finished product. It will be a length adapted Hurst exponent calculation designed specifically for breakouts.

@MattATM How do I get it to reset if the resistance value changes, sometimes a individual resistance will move down and the count doesn't reset. I tried resistance1 ==resistance1[1] as a requirement with no luck.

here's my current line of code and picture of the dilemma:

def ur = CompoundValue(1, if Price < Resistance1 and resistance1 == resistance1[1] then ur[1] + 1 else if price[1] > Resistance1 then 0 else ur[1], 0);
plot x = ur;

notice how the resistance drops but it doesn't reset

You can reset the resistance values once something happens after each Break Out like if a certain relative volume is met or if the security creates a new Defended Price Line.
Oh I realized I am way behind cause I didn't touch the supports & resistances themselves. I just used them to count breakUP and BreakDOWN in our last email...

In the lower the blue counts the number of candles inside Support & Resistance once it has reset, The green counts Breakout UP the Red counts Breakout DOWN.

The Hurst Exponent looks beautiful and elegant... I wonder if it could be sped up with the defended price lines... Suppose if in PLUG a deliberate volume existed somewhere it forms a S&R but it could also mean those buyers want to take profits into the Breakout.

Last edited:

Not the exact question you're looking for?

87k+ Posts
518 Online

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?