Use a profile of close, to find the MODE of a period

halcyonguy

Moderator - Expert
VIP
Lifetime
Use a profile of close, to find the MODE of a period.

this will find the MODE of a collection of prices, over a time period,
the close price (range) that occurs with the greatest frequency.

use a profile of close, to find the POC, point of control, the MODE of the period.

can choose profile row type,
. automatic (85 rows)
. ticksize (usually 0.01)
. number (enter a number of a price range)


labels for,
ticksize, row type, MODE price, profile highest price, profile lowest price, profile range.

Ruby:
# profile_close_03

# https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Profiles/DataProfile
# DataProfile
#   default row qty = 85
# -------------------------------------

def t = ticksize();
addlabel(1, "ticksize " + t, color.yellow);

input pick_row_type = { default auto , tick , number };

#hint pick_row_type: Row height. \n -- auto , calculated automatically, 85 rows. \n -- tick , ticksize, 0.01 for most stocks. \n -- number , enter a price number to define the height of each row.

input row_height_number = 0.25;

def ppr;
switch (pick_row_type) {
  case auto:
    ppr = PricePerRow.AUTOMATIC;
  case tick:
    ppr = PricePerRow.TICKSIZE;
  case number:
    ppr = row_height_number;
}

addlabel(1, " row type " + pick_row_type , color.yellow);

# stuff from volumeprofile
input showPointOfControl = yes;
input showValueArea = no;  #hint showValueArea: "light shading around the horz lines"
input valueAreaPercent = 70;
input opacity = 20;


def cls = close;
def condition = GetYear() != GetYear()[1];

# "onExpansion" = onExpansion
# yes, place to the right.  no, place over candles
input onExpansion = no;

profile CustomProfile = DataProfile(data = cls, pricePerRow = ppr, onExpansion = onExpansion, startNewProfile = condition);

CustomProfile.Show();
plot POC = CustomProfile.GetPointOfControl();

addlabel(1, "MODE, close price of highest reoccurance " + poc, color.yellow);

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

CustomProfile.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);

def maxp = CustomProfile.GetHighest();
def minp = CustomProfile.Getlowest();

addlabel(1, "profile highest " + maxp, color.yellow);
addlabel(1, "profile lowest " + minp, color.yellow);
def profile_range = maxp - minp;
addlabel(1, "profile range " + profile_range, color.yellow);
#

hQffRHm.jpg


DataProfile
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Profiles/DataProfile

info on MODE
https://www.microeconomicsnotes.com...e-with-examples-formula-merits-demerits/15177

https://www.purplemath.com/modules/meanmode.htm
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
347 Online
Create Post

Similar threads

Similar threads

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