MID price indicator for TOS - futures io
futures io futures trading



MID price indicator for TOS


Discussion in ThinkOrSwim

Updated by keifer
      Top Posters
    1. looks_one smegey with 5 posts (0 thanks)
    2. looks_two devildriver6 with 3 posts (9 thanks)
    3. looks_3 Shortline with 2 posts (0 thanks)
    4. looks_4 Semifaded with 2 posts (0 thanks)
    1. trending_up 4,931 views
    2. thumb_up 9 thanks given
    3. group 11 followers
    1. forum 17 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Thread Tools Search this Thread
 

MID price indicator for TOS

  #11 (permalink)
Dallas, Texas
 
 
Posts: 43 since Jun 2015
Thanks: 2 given, 28 received


Shortline View Post
The logic of the script combined with ToS methodology is causing the recursive function to start one bar later than intended.

If you set the following two inputs to 1 bar prior to what you actually want the script will work accurately:

CapturePeriodStart
StartPlotTime

For example, if you are using a 5 minute intraday chart, if you set the above tow parameters to 0925 the values will be correct.

Unfortunately, if you change timeframes without adjusting these parameters it the midline will be inaccurate again.

I'm sure there is some logic that could be built into the script but I did not take the time to investigate that, sorry.

Additional Note: I just realized that if the chart is not showing the extended trading hours session the above hack does not work. Back to the drawing board.




For everyone following this thread, I figured out a more "elegant" way to do this, which is now correct.
This will reset daily, regardless of timeframe (as long as the timeframe is lower than the midpoint you're tracking), as well as provides Daily, Weekly, and Monthly midpoints, as desired.

Lastly, this gives you the option to see the High and Low it's using or hide it, as needed, and rounds the Mid Point to the nearest tick value.

Here's what it looks like (showing the high and low, which you can hide):



Here's the code:
## Provided by @The_Dude_Trader on Stocktwits / Twitter##
## For personal use only##
## Come see more at @DTWCoachandDude on Stocktwits / Twitter / Facebook ##
## https://www.secretsociety7.com/ ##


input timeFrame = {default DAY, WEEK, MONTH} ;
input ShowHiLo = no ;


def cap = GetAggregationPeriod() ;
def errorInAggregation =
timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH ;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period") ;

def yyyyMmDd = GetYYYYMMDD() ;
def periodIndx;
switch (timeFrame) {
case DAY:
periodIndx = yyyyMmDd ;
case WEEK:
periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7) ;
case MONTH:
periodIndx = RoundDown(yyyyMmDd / 100, 0) ;
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes) ;

def HI ;
def LO ;

if (isPeriodRolled) {
HI = high ;
LO = low ;
} else {
HI = if high > HI[1] then high else HI[1] ;
LO = if low < LO[1] then low else LO[1] ;
}

def NA = double.NaN ;

plot TheHI = if ShowHiLo then HI else NA ;
plot TheLO = if ShowHiLo then LO else NA ;
plot TheMid = round(((HI + LO) / 2) / ticksize(), 0) * ticksize();

TheHI.setdefaultColor(color.green) ;
TheLO.setdefaultColor(color.red) ;
TheMid.setdefaultColor(color.yellow) ;
TheMid.setlineweight(2) ;


Last edited by devildriver6; March 21st, 2018 at 12:31 PM.
Reply With Quote
The following 7 users say Thank You to devildriver6 for this post:

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
ThinkOrSwim
Moving average with Lag reduction
NinjaTrader
Linux?
ThinkOrSwim
 
 
  #12 (permalink)
Lake Stevens, WA
 
Experience: Intermediate
Platform: NinjaTrader, TOS, IB exec
Broker: Interactive Brokers
Trading: ES CL
 
Shortline's Avatar
 
Posts: 46 since Aug 2016
Thanks: 38 given, 43 received


devildriver6 View Post
For everyone following this thread, I figured out a more "elegant" way to do this, which is now correct.

Nice update! It is very elegant.

I like it. Thanks for sharing.

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
  #13 (permalink)
New Orleans, Louisiana
 
Experience: Beginner
Platform: ThinkOrSwim
Trading: Emini
 
Posts: 1 since Apr 2017
Thanks: 1 given, 0 received



devildriver6 View Post
For everyone following this thread, I figured out a more "elegant" way to do this, which is now correct.
;

The devil's in the details, as you already know, devildriver6. This indicator is quite elegant, and I love it, man. I have been looking for this for quite a while. You are da' man! Thank you very much!


Reply With Quote
 
  #14 (permalink)
Kingston, New York USA
 
 
Posts: 1 since Jun 2019
Thanks: 0 given, 0 received

A Thousand Thanks! ...

You have made my dream come true ... I'd been searching for a means of creating a mid-point indicator for my TOS intraday futures charts and some midnight cyber-surfing landed me here at Futures IO and your kind contribution to traders unable to craft Think Script ... Kind folks like you make the internet a wonder-filled playground ... Thanks again, George J Nicholson

Reply With Quote
 
  #15 (permalink)
los angeles + ca/usa
 
 
Posts: 1 since May 2017
Thanks: 0 given, 0 received

Thanks for the script

I had a simple version and this one really fits the bill. I struggled creating it on my own til I finally found my senses and found this one. Thanks devil

Reply With Quote
 
  #16 (permalink)
Dallas, TX USA
 
 
Posts: 1 since Aug 2012
Thanks: 1 given, 0 received


nick0102 View Post
I had a simple version and this one really fits the bill. I struggled creating it on my own til I finally found my senses and found this one. Thanks devil

Ditto this ^^^^^^ from fellow Texan!

Reply With Quote
 
  #17 (permalink)
Grand Rapids MI
 
 
Posts: 2 since Sep 2019
Thanks: 0 given, 1 received

Thanks for sharing your expertise with the mid-point indicator!

Reply With Quote
 
  #18 (permalink)
San Francisco California USA
 
Experience: Beginner
Platform: ThinkorSwim
Broker: ThinkorSwim
Trading: RTY
 
Posts: 4 since May 2013
Thanks: 4 given, 1 received

Thanks so much

Thank you so much for your skill in coding.

I've been looking high and low for this High, Low, Mid code.
I was plotting it manually, this will be such a time saver.

-Keifer

Reply With Quote



futures io Trading Community Platforms and Indicators ThinkOrSwim > MID price indicator for TOS




Upcoming Webinars and Events
 

Understanding Order Flow Stop Runs & Icebergs w/Bookmap

May 28
 

Free BloodHound Licenses to everyone!

June
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts