NexusFi: Find Your Edge


Home Menu

 





user input specific time in TOS script.


Discussion in ThinkOrSwim

Updated
    1. trending_up 7,616 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

user input specific time in TOS script.

  #1 (permalink)
 Stocktrader 
Dublin Ireland
 
Experience: Intermediate
Platform: Ninja, TOS
Broker: RCG Direct/Continuum
Trading: ZB
Posts: 18 since Mar 2012
Thanks Given: 4
Thanks Received: 7

I am trying to draw the TOS TPOProfile indicator from a user input specific time - say 7am - using a tick chart. Obviously a tick derived bar may not start at exactly 7am. How do I achieve this?

I have created an input starttime = 0700; (for 7am) and then replaced the (0) in line 18 with starttime but I am still not drawing the profile from 7am or the bar that opens after 7am.

I have tried lots of other combinations and permutations (and crashed TOS !) but with no success.

I have been through the other indicators but cannot find an example to copy - if you know of any please point me in the right direction or point out where I am going wrong.

Thanks.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
 
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
  #2 (permalink)
HaydenP
Carthage Texas Usa
 
Posts: 15 since Jun 2015
Thanks Given: 0
Thanks Received: 2


Stocktrader View Post
I am trying to draw the TOS TPOProfile indicator from a user input specific time - say 7am - using a tick chart. Obviously a tick derived bar may not start at exactly 7am. How do I achieve this?

I have created an input starttime = 0700; (for 7am) and then replaced the (0) in line 18 with starttime but I am still not drawing the profile from 7am or the bar that opens after 7am.

I have tried lots of other combinations and permutations (and crashed TOS !) but with no success.

I have been through the other indicators but cannot find an example to copy - if you know of any please point me in the right direction or point out where I am going wrong.

Thanks.

To the best of my knowledge this may be a little trick because of the way aggregation time is done on intra-day. You have to do some math in the script and divide 3600 for hour, 1800 for 30 min and so on. But that is with a time chart. I will have to check about the tick charts and secondary aggregation. If you need more help let me know

Reply With Quote
Thanked by:
  #3 (permalink)
 Stocktrader 
Dublin Ireland
 
Experience: Intermediate
Platform: Ninja, TOS
Broker: RCG Direct/Continuum
Trading: ZB
Posts: 18 since Mar 2012
Thanks Given: 4
Thanks Received: 7


Hi thanks for taking a look - You are right regards the aggregation in TOS. I haven't spent much time on this yet this week.

I have been trying to convert code from my NT indy but it looks like I will have to create an imaginative work around in order to define the start bar for drawing the profile. This is easy using a timed based aggregation and is already a feature of the indy but getting it to draw a profile from the bar nearest to 7am or whatever the user inputs when using tick derived bars is proving a headache.

I have found a pivot indicator that uses an input to draw the lines 'from' and 'to' - I will test this with tick bars and see how it works - a bit long winded but it may be a work around.

I will keep posting and any other input gratefully received.

Ben.

Just to be clear I want to draw a profile say every 4 hours using the existing settings within the indy but I want to be able to specify that it starts the profile at say 6am using a tick derived bar - NOT the first bar of the session.
It may be a case of defining something like startbar = the nth bar after the start of the session that is closest to the users input time. In NT this is easy - if it's easy in TOS please let me know - I haven't engaged the cogs on this line of thought yet!

Started this thread Reply With Quote
  #4 (permalink)
HaydenP
Carthage Texas Usa
 
Posts: 15 since Jun 2015
Thanks Given: 0
Thanks Received: 2


Stocktrader View Post
Hi thanks for taking a look - You are right regards the aggregation in TOS. I haven't spent much time on this yet this week.

I have been trying to convert code from my NT indy but it looks like I will have to create an imaginative work around in order to define the start bar for drawing the profile. This is easy using a timed based aggregation and is already a feature of the indy but getting it to draw a profile from the bar nearest to 7am or whatever the user inputs when using tick derived bars is proving a headache.

I have found a pivot indicator that uses an input to draw the lines 'from' and 'to' - I will test this with tick bars and see how it works - a bit long winded but it may be a work around.

I will keep posting and any other input gratefully received.

Ben.

I was in error in the post I sent.....I will test it correctly and get back.

Hayden

Reply With Quote
  #5 (permalink)
HaydenP
Carthage Texas Usa
 
Posts: 15 since Jun 2015
Thanks Given: 0
Thanks Received: 2


Stocktrader View Post
Hi thanks for taking a look - You are right regards the aggregation in TOS. I haven't spent much time on this yet this week.

I have been trying to convert code from my NT indy but it looks like I will have to create an imaginative work around in order to define the start bar for drawing the profile. This is easy using a timed based aggregation and is already a feature of the indy but getting it to draw a profile from the bar nearest to 7am or whatever the user inputs when using tick derived bars is proving a headache.

I have found a pivot indicator that uses an input to draw the lines 'from' and 'to' - I will test this with tick bars and see how it works - a bit long winded but it may be a work around.

I will keep posting and any other input gratefully received.

Ben.

Just to be clear I want to draw a profile say every 4 hours using the existing settings within the indy but I want to be able to specify that it starts the profile at say 6am using a tick derived bar - NOT the first bar of the session.
It may be a case of defining something like startbar = the nth bar after the start of the session that is closest to the users input time. In NT this is easy - if it's easy in TOS please let me know - I haven't engaged the cogs on this line of thought yet!

What indicator were you using in NT. I want to see if I can convert it with some of this software I have collected over the years.

Reply With Quote
  #6 (permalink)
 Stocktrader 
Dublin Ireland
 
Experience: Intermediate
Platform: Ninja, TOS
Broker: RCG Direct/Continuum
Trading: ZB
Posts: 18 since Mar 2012
Thanks Given: 4
Thanks Received: 7

NT script below is from the DrawVerticalLine indy – you can also look at the dValue indy. In NT you can simply use

Bars.GetBar() or you can use BarsSinceSession()

The problem in TOS is identifying the bar that opens after the user input time (just to keep it simple) - if we wanted to get the closest open to the users input time we would have to compare open[0] and open[1] then plot ….. but the main problem is identifying the bar to start the plot from.

I will be able to do more on this at the weekend.

Ben.



protected override void OnBarUpdate()
{
if (CurrentBar < 1) { return; }
// Determine if this bar fits the time parameters and plot if so...
if (Time[0].TimeOfDay.CompareTo(timeToPlot) >= 0 && Time[1].TimeOfDay.CompareTo(timeToPlot) < 0)
{
this.DrawLine("VertTop" + CurrentBar.ToString(), false, Time[0], High[0] + (BarToLineOffsetInTicks * TickSize), Time[0],
High[0] + LineLengthInTicks*TickSize, LineColor, LineStyle, LineSize);

this.DrawLine("VertBottom" + CurrentBar.ToString(), false, Time[0], Low[0] - (BarToLineOffsetInTicks * TickSize), Time[0],
Low[0] - LineLengthInTicks*TickSize, LineColor, LineStyle, LineSize);

DrawText("" + CurrentBar.ToString(), true, LineLabel,0, Low[0] - ((LineLengthInTicks*TickSize) + LabelOffset*TickSize),0, LineColor, TextFont, Alignment, Color.Transparent, Color.Transparent, 0);// ORIGINAL - ("" + CurrentBar.ToString(), LineLabel, 0, Low[0] - ((LineLengthInTicks*TickSize) + 4*TickSize), LineColor); //Instrument.MasterInstrument.Name + "\n" +
PlaySound(@"OpeningBell.wav");
}

Started this thread Reply With Quote
  #7 (permalink)
HaydenP
Carthage Texas Usa
 
Posts: 15 since Jun 2015
Thanks Given: 0
Thanks Received: 2


Stocktrader View Post
NT script below is from the DrawVerticalLine indy – you can also look at the dValue indy. In NT you can simply use

Bars.GetBar() or you can use BarsSinceSession()

The problem in TOS is identifying the bar that opens after the user input time (just to keep it simple) - if we wanted to get the closest open to the users input time we would have to compare open[0] and open[1] then plot ….. but the main problem is identifying the bar to start the plot from.

I will be able to do more on this at the weekend.

Ben.


Code Removed to save space
}

Are you trying to start from a time that you input, and are you using Tick or time based aggregation.

I don't suppose this would help ...?

input StartAggregation= 0930;
input StartPlotTime= 1;
def durationSec = StartPlotTime* 60 * 60;
def secondsPassed = SecondsFromTime(OpenTime);
plot Price = if secondsPassed >= 0 and secondsPassed <= durationSec then close else double.NaN;

H

One other thing I forgot to mention is that a limitation of ToS is that the lowest time frame that cn be accessed on a tick chart is 1 day

Reply With Quote
Thanked by:
  #8 (permalink)
 Stocktrader 
Dublin Ireland
 
Experience: Intermediate
Platform: Ninja, TOS
Broker: RCG Direct/Continuum
Trading: ZB
Posts: 18 since Mar 2012
Thanks Given: 4
Thanks Received: 7

Think i have got to the bottom of this one - haven't solved it completely as I have been busy but the Volume profile has a StartNewProfile parameter. All one needs to do is define the start time and then plot the profile turns out to be quite simple i think. All you have to do is write the condition if open of current bar is > 7am(user input time) then profile myProfile = VolumeProfile(Symbol, PricePerRow.TickSize, myStartCondition, Not on expansion, #ofprofiles 6, Va=68%);
myProfile.Show(.....etc );

obviously I haven't tested this yet but will get round to it this week.

Started this thread Reply With Quote




Last Updated on July 19, 2015


© 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