Coding horizontal line at specific bar - futures io
futures io futures trading



Coding horizontal line at specific bar


Discussion in ThinkOrSwim

Updated by CodingDummy
    1. trending_up 718 views
    2. thumb_up 7 thanks given
    3. group 2 followers
    1. forum 12 replies
    2. attach_file 2 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)

 
Search this Thread
 

Coding horizontal line at specific bar

(login for full post details)
  #1 (permalink)
Sacramento, California
 
 
Posts: 10 since Sep 2019
Thanks: 6 given, 1 received

on Thinkorswim.

I am looking for a script to do the following:

I want a light blue colored horizontal line drawn using the closing price of the first 5 minute candle in after hours trading (the one from 16:00-16:05 EST). Wherever this candle closes, a horizontal line is drawn in light blue that shows price level name as "LIS" and shows Price on the right. No matter what time frame we move to I want this line to be permanent for the next trading day only. Each day a new line is generated and we don’t see any prior lines.

Based on SHAK today (9/9/19), that line would be generated at 102.66 from 16:05 today (9/19). i don't care how long it extends into the future as long as it covers the entire trading day that follows.

please help me, i'm a coding dummy

Reply With Quote

Can you help answer these questions
from other members on futures io?
help to convert from thinkscript to ninjascript
NinjaTrader
is there an easy way to obtain by code the price variation percentual
MultiCharts
Where is the link to download GomiRecorder?
NinjaTrader
How to place NT8 indicator output into a grid, under each bar?
NinjaTrader
IB Bracker Order
Platforms and Indicators
 
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 632 since Dec 2018
Thanks: 1,663 given, 1,349 received


CodingDummy View Post
on Thinkorswim.

I am looking for a script to do the following:

I want a light blue colored horizontal line drawn using the closing price of the first 5 minute candle in after hours trading (the one from 16:00-16:05 EST). Wherever this candle closes, a horizontal line is drawn in light blue that shows price level name as "LIS" and shows Price on the right. No matter what time frame we move to I want this line to be permanent for the next trading day only. Each day a new line is generated and we don’t see any prior lines.

Based on SHAK today (9/9/19), that line would be generated at 102.66 from 16:05 today (9/19). i don't care how long it extends into the future as long as it covers the entire trading day that follows.

please help me, i'm a coding dummy

It is going to be something like:

def C = close;
plot closingprice = if secondsfromtime(1605)<=0 and secondstilltime(1605)>=0 then C else if secondsfromtime(1605)>0 then c[1];

I am not sure if that will work as I am typing away from my TOS platform. If it does not then I will fix it tomorrow at some point.

Visit my futures io Trade Journal Reply With Quote
The following 2 users say Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #3 (permalink)
Legendary Market Wizard
Portland, OR
 
Experience: None
 
Massive l's Avatar
 
Posts: 1,905 since Mar 2011
Thanks: 1,514 given, 3,676 received



mtzimmer1 View Post
It is going to be something like:

def C = close;
plot closingprice = if secondsfromtime(1605)<=0 and secondstilltime(1605)>=0 then C else if secondsfromtime(1605)>0 then c[1];

I am not sure if that will work as I am typing away from my TOS platform. If it does not then I will fix it tomorrow at some point.

killing to coding game @mtzimmer1

error on else if with this one

Reply With Quote
The following user says Thank You to Massive l for this post:
 
(login for full post details)
  #4 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 632 since Dec 2018
Thanks: 1,663 given, 1,349 received


Massive l View Post
killing to coding game @mtzimmer1



error on else if with this one



Right... ya need another “else” after the “else if” in case neither of the aforementioned conditions are met. Adding an “else double.nan” at the end of the string would resolve it I think?

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #5 (permalink)
Sacramento, California
 
 
Posts: 10 since Sep 2019
Thanks: 6 given, 1 received

It’s like you guys are speaking Russian to me right now. Can’t tell you how much u appreciate help like this

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 632 since Dec 2018
Thanks: 1,663 given, 1,349 received

It is great practice for me as a novice coder! Try this out and tell me if it takes or not.



def C = close;

plot closingprice = if secondsfromtime(1605)<=0 and secondstilltime(1605)>=0 then C else if secondsfromtime(1605)>0 then c[1]
else double.nan;

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #7 (permalink)
Sacramento, California
 
 
Posts: 10 since Sep 2019
Thanks: 6 given, 1 received

this didn't work. i just end up with lines on every bar. let take a screen shot of what im looking for it to dispaly

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 632 since Dec 2018
Thanks: 1,663 given, 1,349 received

Hey I'll get the code up and working tonight after work. Should be a quick fix!

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #9 (permalink)
Sacramento, California
 
 
Posts: 10 since Sep 2019
Thanks: 6 given, 1 received



here is what the SHAK chart would look like.
the 16:00-16:05 candle closed at 102.66, so i have manually drawn the aqua line from the 16:00 mark as seen in the picture.

i change time frames, so what i want to happen is that when i go from 5m chart to 4hr or daily chart that the line does not then move to the closing price of those charts. always needs to reference that 5min closing price on the 16:00-16:05 candle.

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 632 since Dec 2018
Thanks: 1,663 given, 1,349 received


Hey man, this DOES work but it is not pretty. You need to enter periodstarttime as the first 1 minute bar that prints in the pre-market trading hours. Also the periodendtime as the periodstarttime + 0001. Sorry I was unable to create a prettier code!


declare upper;

input PeriodStartTime = 0458;
input PeriodEndTime = 0459;


def Range_Top = if SecondsFromTime(1606) >= 0 then Range_Top[1] else
if SecondsFromTime(1605) == 0 then close else
if SecondsFromTime(1605) < 0 then Double.NaN else
if SecondsFromTime(1605) > 0 and SecondsFromTime(1606) <= 0
and close > Range_Top[1] then close else Range_Top[1];

plot line = Range_Top;


def line_Top = if SecondsFromTime(periodendtime) >= 0 then line_Top[1] else
if SecondsFromTime(PeriodStartTime) == 0 then line[1] else
if SecondsFromTime(PeriodStartTime) < 0 then Double.NaN else
if SecondsFromTime(PeriodStartTime) > 0 and SecondsFromTime(PeriodEndTime) <= 0
and line[1] > line_Top[1] then line[1] else line_Top[1];

plot line2 = line_top;

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:


futures io Trading Community Platforms and Indicators ThinkOrSwim > Coding horizontal line at specific bar


September 12, 2019


Upcoming Webinars and Events
 

Getting Comfortable with Price Action Patterns w/Earn2Trade

Aug 4
 

Live Video Panel: Ask Me Anything w/Ironbeam Brokerage

Aug 6
     



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