Highest High and Lowest Low two times frames

Chiguette

New member
Hello,

I'm new to ThinkScript. I am trying to create script to search for the Highest High and the Lowest Low between two intra daytime frames.
As an example:
the ideal script would return: the highest High between 9:35am and 12:00pm (and the lowest Low for the same time frame) for the last 3 days.

Is this possible?

Thank you in advance for your hep.
 
Solution
Hello,

I'm new to ThinkScript. I am trying to create script to search for the Highest High and the Lowest Low between two intra daytime frames.
As an example:
the ideal script would return: the highest High between 9:35am and 12:00pm (and the lowest Low for the same time frame) for the last 3 days.

Is this possible?

Thank you in advance for your hep.

See if this helps

Screenshot-2023-04-13-124343.png
Code:
#Range_Developing_in_Separate_Cloud_Color
script r {
    input oTime = 0935;
    input cTime = 1200;
    input extend = yes;
    input showlastonly = yes;

    def sec1 = SecondsFromTime(oTime);
    def sec2 = SecondsFromTime(cTime);
    def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0);
    def isTime2 = (sec2 >= 0...
Hello,

I'm new to ThinkScript. I am trying to create script to search for the Highest High and the Lowest Low between two intra daytime frames.
As an example:
the ideal script would return: the highest High between 9:35am and 12:00pm (and the lowest Low for the same time frame) for the last 3 days.

Is this possible?

Thank you in advance for your hep.

See if this helps

Screenshot-2023-04-13-124343.png
Code:
#Range_Developing_in_Separate_Cloud_Color
script r {
    input oTime = 0935;
    input cTime = 1200;
    input extend = yes;
    input showlastonly = yes;

    def sec1 = SecondsFromTime(oTime);
    def sec2 = SecondsFromTime(cTime);
    def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0);
    def isTime2 = (sec2 >= 0 and sec2[1] < 0) or (sec2 < sec2[1] and sec2 >= 0);
    def inRange = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else inRange[1], 0);
    def bars   = 200000;

    input pricePerRowHeightMode = { AUTOMATIC, default TICKSIZE, CUSTOM};
    input customRowHeight = 1.0;
    input timePerProfile = {default BAR};
    input onExpansion = no;
    input profiles = 3;

    def period;

    switch (timePerProfile) {
    case BAR:
        period = BarNumber() - 1;
}


    def count = CompoundValue(1, if inRange and period != period[1] then (count[1] + period - period[1]) % bars else count[1], 0);
    def cond = count < count[1] + period - period[1];
    def height;
    switch (pricePerRowHeightMode) {
    case AUTOMATIC:
        height = PricePerRow.AUTOMATIC;
    case TICKSIZE:
        height = PricePerRow.TICKSIZE;
    case CUSTOM:
        height = customRowHeight;
}

    profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no,  "pricePerRow" = height, "value area percent" = 0);
    def con = CompoundValue(1, onExpansion, no);

    def hProfile = if inRange and IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();
    def lProfile = if inRange and IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest();
    def plotsDomain = IsNaN(close) == onExpansion;
    def ProfileHigh = if inRange and plotsDomain then hProfile else if extend then ProfileHigh[1] else Double.NaN;
    def ProfileLow  = if inRange and plotsDomain then lProfile else if extend then ProfileLow[1] else Double.NaN;

    def dataCount = CompoundValue(1, if cond != cond[1] then dataCount[1] + 1 else dataCount[1]  , 0);

    plot hrange = if !showlastonly then ProfileHigh else if showlastonly and  HighestAll(dataCount) - dataCount <= if cTime <= 0000 then 2 else 1  then ProfileHigh else Double.NaN;
    plot lrange = if !showlastonly then ProfileLow else if showlastonly and HighestAll(dataCount) - dataCount <= if cTime <= 0000 then 2 else 1  then ProfileLow else Double.NaN;
}

input showclouds = yes;
input showbubbles = yes;
input showbubble_times = yes;
input showlastonly = yes;

input otime1 = 0935;
input ctime1 = 1200;
#Horizontal Lines - Separate input for line_extend was necessary as request was for extended lines, whereas the clouds were not wanted to extend by the times input

input line_extend = yes;
plot r1h = r(otime1, ctime1, extend = line_extend, showlastonly = showlastonly);
plot r1l = r(otime1, ctime1, extend = line_extend, showlastonly = showlastonly).lrange;
plot mid = (r1h + r1l) / 2;


DefineGlobalColor("H", Color.LIGHT_GREEN);
DefineGlobalColor("L", Color.LIGHT_RED);

r1h.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r1l.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

r1h.SetDefaultColor(GlobalColor("H"));
r1l.SetDefaultColor(GlobalColor("L"));


#Clouds - Cloud plots for cloud1-3 hl are needed

input cloud_time_input = yes;
input cloud_extended_time = yes;
plot cloud1h = r(otime1, ctime1, extend = cloud_time_input, showlastonly = showlastonly);
plot cloud1l = r(otime1, ctime1, extend = cloud_time_input, showlastonly = showlastonly).lrange;

DefineGlobalColor("OR", Color.WHITE);
DefineGlobalColor("OR EXT", Color.CYAN);
AddCloud(if showclouds and cloud_time_input then r(otime1, ctime1, extend = no, showlastonly = showlastonly) else Double.NaN, r(otime1, ctime1, extend = no, showlastonly = showlastonly).lrange, GlobalColor("OR"), GlobalColor("OR"));
AddCloud(if showclouds and cloud_extended_time and SecondsFromTime(ctime1) >= 0 then r(otime1, ctime1, extend = cloud_extended_time, showlastonly = showlastonly) else Double.NaN, r(otime1, ctime1, extend = cloud_extended_time, showlastonly = showlastonly).lrange, GlobalColor("OR EXT"), GlobalColor("OR EXT"));

input bubblemover = 5;
def b  = bubblemover;
def b1 = b + 1;
def mover = showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]);

AddChartBubble(mover, r1h[b1],
if showbubble_times then AsPrice(otime1) + " : " + AsPrice(ctime1) + "\nH: " + AsText(r1h) else "H: " + AsText(r1h), r1h.TakeValueColor());
AddChartBubble(mover, r1l,
if showbubble_times then AsPrice(otime1) + " : " + AsPrice(ctime1) + "\nL: " + AsText(r1l) else "L: " + AsText(r1l),  r1l.TakeValueColor(), up = no);
AddChartBubble(mover, mid,
if showbubble_times then AsPrice(otime1) + " : " + AsPrice(ctime1) + "\nM: " + AsText(mid) else "M: " + AsText(mid),  mid.TakeValueColor(), up = no);
 
Solution

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
316 Online
Create Post

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