candle is closing at its top 25% @3pm

HushPuppy

New member
VIP
Good day any chance of converting this Indicator into a scan that I can run at about 3:00 EST to see if the candle is closing at its top 25%?

That way I can Buy prior to market close?

Just looking to see if this is possible. Thanks for your time

https://usethinkscript.com/threads/above-the-stomach-candle-indicator-for-thinkorswim.25/
Ruby:
input BubbleOn = yes;

def downTrend = isDescending(high[1], 3) and isDescending(low[1], 3);
def AboveStomach = open > close[1] and close > high[1] and close > open;

plot isTrue = if downtrend and
                 AboveStomach
              then low
              else double.nan;

     isTrue.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     isTrue.SetLineWeight(3);
     isTrue.SetDefaultColor(Color.CYAN);

AddChartBubble(BubbleOn and isTrue, isTrue, "Above Stomach", color.cyan, yes);

# End Code Above Stomach Candle

Cheers
Hush !
 
Last edited by a moderator:
Solution
Good day any chance of converting this Indicator into a scan that I can run at about 3:00 EST to see if the candle is closing at its top 25%?

That way I can Buy prior to market close?

Just looking to see if this is possible. Thanks for your time

https://usethinkscript.com/threads/above-the-stomach-candle-indicator-for-thinkorswim.25/
Ruby:
input BubbleOn = yes;

def downTrend = isDescending(high[1], 3) and isDescending(low[1], 3);
def AboveStomach = open > close[1] and close > high[1] and close > open;

plot isTrue = if downtrend and
                 AboveStomach
              then low
              else double.nan;

     isTrue.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     isTrue.SetLineWeight(3)...
Good day any chance of converting this Indicator into a scan that I can run at about 3:00 EST to see if the candle is closing at its top 25%?

That way I can Buy prior to market close?

Just looking to see if this is possible. Thanks for your time

https://usethinkscript.com/threads/above-the-stomach-candle-indicator-for-thinkorswim.25/
Ruby:
input BubbleOn = yes;

def downTrend = isDescending(high[1], 3) and isDescending(low[1], 3);
def AboveStomach = open > close[1] and close > high[1] and close > open;

plot isTrue = if downtrend and
                 AboveStomach
              then low
              else double.nan;

     isTrue.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     isTrue.SetLineWeight(3);
     isTrue.SetDefaultColor(Color.CYAN);

AddChartBubble(BubbleOn and isTrue, isTrue, "Above Stomach", color.cyan, yes);

# End Code Above Stomach Candle

Cheers
Hush !

no. that code doesn't have end of day code or bar percent code.
easier to start over.

here is a lower that should work as a scan

Code:
# lastbar_topofbar_0_lower

declare lower;

def na = double.nan;
def bn = barnumber();
def d = getday();
def istoday = d == getlastday();

def ht = high - low;
def close_per = round(100*(high-close)/ht,1);

input close_top_percent = 25;
def close_is_high = close_per <= close_top_percent;
#def top_per_level = (100-close_top_percent)/100 * ht + low;

input only_last_bar_of_day = yes;


# ref  korygill
# find first and last bars of day
# https://usethinkscript.com/threads/finding-the-first-and-last-bar-of-the-day-in-thinkorswim.526/
def Offset = 0;
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1+offset] == 1 and beforeStart[offset] == 0) or
    (isRollover[offset] and beforeStart[offset] == 0) then 1
    else 0;
def lastBarOfDay = if (afterEnd[-1-offset] == 1 and afterEnd[offset] == 0) or
    (isRollover[-1-offset] and firstBarOfDay[-1-offset]) then 1
    else 0;

def barz = if only_last_bar_of_day then lastBarOfDay else 1;

# scan line. 
plot z = barz and close_is_high;
#


----------------------------

here is an upper to experiment with different inputs

Code:
# lastbar_topofbar_0

def na = double.nan;
def bn = barnumber();
def d = getday();
def istoday = d == getlastday();

def ht = high - low;
def close_per = round(100*(high-close)/ht,1);

input close_top_percent = 25;
def close_is_high = close_per <= close_top_percent;
def top_per_level = (100-close_top_percent)/100 * ht + low;

input only_last_bar_of_day = yes;

# ref  korygill
# find first and last bars of day
# https://usethinkscript.com/threads/finding-the-first-and-last-bar-of-the-day-in-thinkorswim.526/
def Offset = 0;
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1+offset] == 1 and beforeStart[offset] == 0) or
    (isRollover[offset] and beforeStart[offset] == 0) then 1
    else 0;
def lastBarOfDay = if (afterEnd[-1-offset] == 1 and afterEnd[offset] == 0) or
    (isRollover[-1-offset] and firstBarOfDay[-1-offset]) then 1
    else 0;


def barz = if only_last_bar_of_day then lastBarOfDay else 1;

# scan line. 
#plot z = barz and close_is_high;

# scan line. 
#plot z = barz and close_is_high;

#---------------------------------
# test stuff
# delete lines after this when using as a scan

input show_arrow = no;
plot zup = if show_arrow and close_is_high and lastBarOfDay then low*0.999 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.green);
zup.setlineweight(3);
zup.hidebubble();


input day_first_last_bubbles = no;
#   bubbles on the first and last bars of day
AddChartBubble(day_first_last_bubbles and firstBarOfDay, high, "First", Color.GREEN, yes);
AddChartBubble(day_first_last_bubbles and lastBarOfDay and lastBarOfDay[1] == 0, high, "Last", Color.GREEN, yes);

 
# plot a line at the top % level
input show_per_level_line = no;
plot zlevel = if show_per_level_line and lastBarOfDay then top_per_level else na;
zlevel.SetPaintingStrategy(PaintingStrategy.horizontal);
zlevel.SetDefaultColor(Color.cyan);
zlevel.setlineweight(2);
zlevel.hidebubble();


input show_top_percent = no;
addchartbubble(show_top_percent and lastBarOfDay , low*0.997,
"top %\n" +
close_per
, color.yellow,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
252 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