help code multiple Time Frame indicator - ThinkOrSwim Programming | futures io social day trading
futures io futures trading


help code multiple Time Frame indicator
Updated: Views / Replies:21,607 / 25
Created: by ttmarok Attachments:1

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 1  
 
Thread Tools Search this Thread
 

help code multiple Time Frame indicator

  #11 (permalink)
Elite Member
Wilson, NC
 
Futures Experience: Intermediate
Platform: thinkorswim
Favorite Futures: NQ
 
zentrade's Avatar
 
Posts: 18 since Dec 2010
Thanks: 1 given, 5 received

onnb, basically I did this in the script i posted...



#
# thinkorswim, inc. (c) 2007
#

input length = 8;
input displace = 0;
input agperiod = { "1 min", default "5 min", "15 min", "30 min", "60 min", "4 hours"};

plot AvgExp = ExpAverage(close(period = agperiod)[-displace], length);
AvgExp.SetStyle(Curve.SHORT_DASH);
AvgExp.SetLineWeight(4);
AvgExp.SetDefaultColor(GetColor(1));


but if you try to calculate a more complicated indicator like macd or stochastics, for some reason the calculations aren't correct when you try to use the calculation in an if-then-else expression or use the def variable (with the higher aggregation period) in another calculation.

Reply With Quote
 
  #12 (permalink)
Onn
Vancouver, Canada
 
Futures Experience: Intermediate
Platform: NinjaTrader, SierraCharts, thinkorswim
Favorite Futures: Stocks
 
Posts: 10 since Sep 2011
Thanks: 0 given, 2 received


zentrade View Post
Is this what you are looking for? I just took the stock Exponential moving avg script and added input for a new time period. I think it would be better if you could gather the OHLC info using the rec statement, but this works fine.

BTW, if anyone knows how to do this using the "rec" statement please let me know.

in order to use the rec command, just replace the "plot" keyword with "rec" and you should be good to go.

Reply With Quote
 
  #13 (permalink)
Onn
Vancouver, Canada
 
Futures Experience: Intermediate
Platform: NinjaTrader, SierraCharts, thinkorswim
Favorite Futures: Stocks
 
Posts: 10 since Sep 2011
Thanks: 0 given, 2 received



zentrade View Post
onnb, basically I did this in the script i posted...

but if you try to calculate a more complicated indicator like macd or stochastics, for some reason the calculations aren't correct when you try to use the calculation in an if-then-else expression or use the def variable (with the higher aggregation period) in another calculation.

yeah - i got that too. not sure why. what you can though is just put the stochastic or macd implementation into your mutli timeframe code like this (just change the aggregation period as you like):

declare lower;
input KPeriod = 10;
input DPeriod = 10;
input slowing_period = 3;

plot FullK = Average((close(period = AggregationPeriod.WEEK) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) / (Highest(high(period = AggregationPeriod.WEEK), KPeriod) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) * 100, slowing_period);

plot FullD = Average(Average((close(period = AggregationPeriod.WEEK) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) / (Highest(high(period = AggregationPeriod.WEEK), KPeriod) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) * 100, slowing_period), DPeriod);

the above is taken from ToS documentation, nothing genius on my part

Reply With Quote
 
  #14 (permalink)
Elite Member
Wilson, NC
 
Futures Experience: Intermediate
Platform: thinkorswim
Favorite Futures: NQ
 
zentrade's Avatar
 
Posts: 18 since Dec 2010
Thanks: 1 given, 5 received


onnb View Post
yeah - i got that too. not sure why. what you can though is just put the stochastic or macd implementation into your mutli timeframe code like this (just change the aggregation period as you like):

declare lower;
input KPeriod = 10;
input DPeriod = 10;
input slowing_period = 3;

plot FullK = Average((close(period = AggregationPeriod.WEEK) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) / (Highest(high(period = AggregationPeriod.WEEK), KPeriod) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) * 100, slowing_period);

plot FullD = Average(Average((close(period = AggregationPeriod.WEEK) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) / (Highest(high(period = AggregationPeriod.WEEK), KPeriod) - Lowest(low(period = AggregationPeriod.WEEK), KPeriod)) * 100, slowing_period), DPeriod);

the above is taken from ToS documentation, nothing genius on my part

I thought about doing that too but the scripts I make like this are extremely slow to load. Was thinking that a "rec" solution would be much faster and cleaner.

Reply With Quote
 
  #15 (permalink)
Onn
Vancouver, Canada
 
Futures Experience: Intermediate
Platform: NinjaTrader, SierraCharts, thinkorswim
Favorite Futures: Stocks
 
Posts: 10 since Sep 2011
Thanks: 0 given, 2 received


zentrade View Post
I thought about doing that too but the scripts I make like this are extremely slow to load. Was thinking that a "rec" solution would be much faster and cleaner.

what do you mean by a "rec" solution?

Reply With Quote
 
  #16 (permalink)
Elite Member
Wilson, NC
 
Futures Experience: Intermediate
Platform: thinkorswim
Favorite Futures: NQ
 
zentrade's Avatar
 
Posts: 18 since Dec 2010
Thanks: 1 given, 5 received


onnb View Post
what do you mean by a "rec" solution?

creating this multi timeframe indicator using the "rec" statement instead of changing the aggregation period in the CLOSE statement

Reply With Quote
 
  #17 (permalink)
Onn
Vancouver, Canada
 
Futures Experience: Intermediate
Platform: NinjaTrader, SierraCharts, thinkorswim
Favorite Futures: Stocks
 
Posts: 10 since Sep 2011
Thanks: 0 given, 2 received


zentrade View Post
creating this multi timeframe indicator using the "rec" statement instead of changing the aggregation period in the CLOSE statement

ah...this can sometimes get quite complex - especially if you are developing a general solution to handle all cases.

anyways, so let me see if i get this. say you are doing an average. its the same in principal for stochastic or any other indicator so lets take the average as an example. for the sake of example, lets say we want an average of closing prices.

so your algorithm might look like this:

1. decide where to start the aggregation - on the first bar of the chart might be one possibility. another, more logical to me, might be to always start on a round hour / or 30 min or 5 min - depending on the granularity.

2. next keep a rec variable that holds the closing price after each granularity period and zero otherwise. so for example:

say you are doing 30 min aggregation on a 5 min chart.

closing price on the 5 min chart over the last 7 bars: 1, 2, 3, 4, 5, 6, 7, 8 ,9, 10
your rec variable over this period might look like this: 0, 0, 3, 0, 0, 0, 0, 8, 0, 0, etc.

3. on each time the study is called, you check the time of the current bar. if it is the end of your aggregation period, you store that value in the rec value for this iteration. if it s not the end of the aggregation period, you just put there zero.

4. now, you calculate the average - so for a simple average, you would iterate over the rec variable going back to "length" number of non zero values adding them up and dividing by length.

once you get this down, there are optimizations you can do to this but i wouldn't get into them till i have something that is working as basis first. besides, it might run fast enough so that you don't need the optimizations.

hope this helps,
Onn

Reply With Quote
 
  #18 (permalink)
Elite Member
Wilson, NC
 
Futures Experience: Intermediate
Platform: thinkorswim
Favorite Futures: NQ
 
zentrade's Avatar
 
Posts: 18 since Dec 2010
Thanks: 1 given, 5 received


onnb View Post
ah...this can sometimes get quite complex - especially if you are developing a general solution to handle all cases.
Onn

I guess it can get a little complicated. I'm not very good with think script and wouldn't know where to start with something this tricky. I wish the calculation issues I mentioned earlier wrt using a def assignment from a different aggravation period was fixed. Writing a mtf indicator would be much easier. Is writing mtf indicators much easier in other platforms?

Reply With Quote
 
  #19 (permalink)
Onn
Vancouver, Canada
 
Futures Experience: Intermediate
Platform: NinjaTrader, SierraCharts, thinkorswim
Favorite Futures: Stocks
 
Posts: 10 since Sep 2011
Thanks: 0 given, 2 received


zentrade View Post
. Is writing mtf indicators much easier in other platforms?


i mostly have experience with ToS and SierraChart and a little bit with NT. my 2 cents is that your experience with ToS is similar to the others meaning:

they provide a pretty easy and straightforward way to implement mtf indicators. if you go down this path it is pretty straight forward. this does come with a price in performance though. this price is usually because they implement a general solution to handle all cases that users might require. you can try and improve the performance by implementing it directly on your own (like you are thinking). you improve on performance cuz you can build something very specific and optimize it for your requirements - but that becomes a bit more tricky as you need to understand exactly how the mtf works and all of the outlier cases.

hope this helps,
Onn

Reply With Quote
 
  #20 (permalink)
Just A Dollar And A Dream
belfast, UK
 
Futures Experience: Intermediate
Platform: Ninja Trader 7 / TOS
Broker/Data: Amp
Favorite Futures: ES
 
druM3's Avatar
 
Posts: 40 since Mar 2012
Thanks: 3 given, 32 received


Hi

Is there a version of the MTF EMA that will show time based emas on the range charts?


Thanks

"Just A Dollar And A Dream"
Reply With Quote

Reply



futures io > > > > > help code multiple Time Frame indicator

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Time Frame Bollinger Bands Saroj The Elite Circle 3 April 28th, 2013 03:34 PM
Best time frame for an instrument spikoloco The Elite Circle 9 September 25th, 2011 03:06 PM
Higher Time Frame Inside-Outside Bar Indicator ??? philipp NinjaTrader 2 September 5th, 2011 04:33 PM
NT7 different time frame indicator Zsolt NinjaTrader 2 April 14th, 2010 12:40 PM


All times are GMT -4. The time now is 04:40 PM.

Copyright © 2017 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
Page generated 2017-12-18 in 0.13 seconds with 20 queries on phoenix via your IP 54.221.136.62