NexusFi: Find Your Edge


Home Menu

 





Coding horizontal line at specific bar


Discussion in ThinkOrSwim

Updated
    1. trending_up 4,431 views
    2. thumb_up 7 thanks given
    3. group 2 followers
    1. forum 12 posts
    2. attach_file 2 attachments




 
 

Coding horizontal line at specific bar

 
CodingDummy
Sacramento, California
 
Posts: 10 since Sep 2019
Thanks Given: 6
Thanks Received: 1

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


Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
33 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Bigger Wins or Fewer Losses?
23 thanks
Tao te Trade: way of the WLD
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
 
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918


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.

Follow me on Twitter Visit my NexusFi Trade Journal
Thanked by:
 
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106



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

Visit my NexusFi Trade Journal
Thanked by:
 
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918


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?

Follow me on Twitter Visit my NexusFi Trade Journal
Thanked by:
 
CodingDummy
Sacramento, California
 
Posts: 10 since Sep 2019
Thanks Given: 6
Thanks Received: 1

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

 
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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;

Follow me on Twitter Visit my NexusFi Trade Journal
Thanked by:
 
CodingDummy
Sacramento, California
 
Posts: 10 since Sep 2019
Thanks Given: 6
Thanks Received: 1

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

 
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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

Follow me on Twitter Visit my NexusFi Trade Journal
Thanked by:
 
CodingDummy
Sacramento, California
 
Posts: 10 since Sep 2019
Thanks Given: 6
Thanks Received: 1



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.

 
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918


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;

Follow me on Twitter Visit my NexusFi Trade Journal
Thanked by:

 



Last Updated on September 12, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts