Price Levels With Start And End Times - futures io
futures io futures trading



Price Levels With Start And End Times


Discussion in ThinkOrSwim

Updated by JayC
    1. trending_up 494 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 7 replies
    2. attach_file 1 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
 

Price Levels With Start And End Times

  #1 (permalink)
Wilmington Delaware
 
 
Posts: 15 since May 2019
Thanks: 2 given, 14 received

Price Levels With Start And End Times

Hi,

I am trying to build an indicator that will plot a price line from a defined start time through a defined end time on a certain date. User input would be Date, Start Time, End Time, and Price. Any ideas on how to set this up would be great.

Reply With Quote

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
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Spoo-nalysis ES e-mini futures S&P 500
77 thanks
June Charity Fundraiser - Feeding hungry families
47 thanks
FIO Journal Challenge - June 2020 edition w/SharkIndicators
35 thanks
Fixed vs trailing stops
31 thanks
AMP Futures / AMP Global Review
26 thanks
 
  #2 (permalink)
San Diego, CA
 
Experience: Beginner
Platform: NT8, TOS, Sierra
Trading: Emini ES, Crude CL
 
Posts: 13 since Mar 2019
Thanks: 2 given, 7 received

Hi Joseph,

Not sure if you still need this. The general idea is to set the plot variable to a valid value only when you want the line to draw and to NaN any time you don't want it to draw. So in this example there's a window defined by the date and times provided. Using that you can control when the line starts and ends.

Hope this helps,
Jeremy

 
Code
input userDate = 20200515;
input priceLevel = 2860;
input startTime = 930;
input endTime = 1130;

def isDateActive = if getYyyyMmDd() == userDate then 1 else 0;

def windowActive = isDateActive && SecondsFromTime(startTime) >= 0 && SecondsFromTime(endTime) < 0;

plot plotLevel = if windowActive then priceLevel else Double.NaN;
PriceLevelStartEnd

Reply With Quote
 
  #3 (permalink)
Wilmington Delaware
 
 
Posts: 15 since May 2019
Thanks: 2 given, 14 received


Thank you so much for your reply. I can't get it to work, because my start time is on Globex start time 1800, but the end time is the next day at 1700 (23 hours). If the start time and end time are on the same date, then the script you supplied works great. Would you be able to help with the script for accomplishing that? I still want the start and end time to be input (user) values, because the start time isn't always at exactly 1800.

Thanks,
Joseph H.

Reply With Quote
 
  #4 (permalink)
San Diego, CA
 
Experience: Beginner
Platform: NT8, TOS, Sierra
Trading: Emini ES, Crude CL
 
Posts: 13 since Mar 2019
Thanks: 2 given, 7 received

Yea, combining date and time range is tricky. I'll work on it and let you know how it goes.

JayC

Reply With Quote
 
  #5 (permalink)
Wilmington Delaware
 
 
Posts: 15 since May 2019
Thanks: 2 given, 14 received

Thanks so much, greatly appreciated!!

Reply With Quote
 
  #6 (permalink)
San Diego, CA
 
Experience: Beginner
Platform: NT8, TOS, Sierra
Trading: Emini ES, Crude CL
 
Posts: 13 since Mar 2019
Thanks: 2 given, 7 received

Hi Joseph,

I've created different plots that show or hide depending on how many days are included in the range. This was to manage the different conditions when crossing date boundaries. This seems to work for the cases I've tried, but give it a shot and let me know how it works for you.

JayC

 
Code
input startDate = 20200512;
input endDate = 20200513;
input startTime = 1800;
input endTime = 1700;
input priceLevel = 2850;

def dayCount = endDate - startDate;

def isInBetween = If endDate - startDate <= 0 then No else DaysFromDate(startDate+1) >= 0 && DaysFromDate(endDate) < 0;
def isStart = DaysFromDate(startDate) == 0 && SecondsFromTime(startTime) >= 0;
def isEnd = DaysFromDate(endDate) == 0 && SecondsFromTime(endTime) <= 0;
def isSingleDayWindow = DaysFromDate(startDate) == 0 and SecondsFromTime(startTime) >= 0 and SecondsFromTime(endTime) <= 0;

plot plotLevelSingleDay = if isSingleDayWindow then priceLevel else Double.NaN;
plotLevelSingleDay.setDefaultColor(Color.CYAN);
plotLevelSingleDay.setHiding(dayCount > 0);

plot plotLevelTwoDay = if isStart or isEnd then priceLevel else Double.NaN;
plotLevelTwoDay.setDefaultColor(Color.DARK_ORANGE);
plotLevelTwoDay.setHiding(dayCount != 1);

plot plotLevelMultiDay = if isStart or isEnd or isInBetween then priceLevel else Double.NaN;
plotLevelMultiDay.setDefaultColor(Color.DARK_GREEN);
plotLevelMultiDay.setHiding(dayCount < 2);

Reply With Quote
 
  #7 (permalink)
Wilmington Delaware
 
 
Posts: 15 since May 2019
Thanks: 2 given, 14 received

JayC,

Thank you so much for that code. It works great and does what I needed. Sorry it took so long to get back, I am back to work after having Covid-19 so these 12 hr work days are long. I really appreciated the time you spent getting that together for me.

Reply With Quote
 
  #8 (permalink)
San Diego, CA
 
Experience: Beginner
Platform: NT8, TOS, Sierra
Trading: Emini ES, Crude CL
 
Posts: 13 since Mar 2019
Thanks: 2 given, 7 received

No problem, glad its working for you. Hope you're feeling better.

Take care,
JayC

Reply With Quote



futures io Trading Community Platforms and Indicators ThinkOrSwim > Price Levels With Start And End Times




Upcoming Webinars and Events
 

Free BloodHound Licenses to everyone!

June
 

Every journal equals ten meals for the hungry

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