trouble adding new time frame to strategy - NinjaTrader Programming | futures io social day trading
futures io futures trading


trouble adding new time frame to strategy
Updated: Views / Replies:2,352 / 12
Created: by jordis 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
 

trouble adding new time frame to strategy

  #1 (permalink)
Elite Member
Mobile, Alabama
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Favorite Futures: Stocks
 
Posts: 29 since Sep 2011
Thanks: 6 given, 4 received

trouble adding new time frame to strategy

I am still a beginner at coding in NT, so I apologize if this question is too basic/generic/obvious. Hopefully it has a quick solution that I am simply an idiot for overlooking!

Problem:
I'm trying to reference multiple time frames in a strategy. What I would like to do is trade in a 5 minute time frame, but I would like to check a daily chart to see if a condition is met by an indicator, and if so I want to cease trading (ie. if the market is doing something that has proven to make my 5 minute strategy ineffective, I would like to stop trading until normalcy returns).

My issue is that my code stops running the instant I add the line for the new period
 
Code
protected override void Initialize()
      {
Add(PeriodType.Day, 1);
}
Without this line, the strategy runs, but as soon as this is added it stops working. I have not even tried to call this later in the code yet. I have tried changing the period to minute, day, etc and it makes no difference.

Can someone give me any idea what I might be missing that is causing this to kill my script?

Thanks in advance,
jordis

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received



jordis View Post
I am still a beginner at coding in NT, so I apologize if this question is too basic/generic/obvious. Hopefully it has a quick solution that I am simply an idiot for overlooking!

Problem:
I'm trying to reference multiple time frames in a strategy. What I would like to do is trade in a 5 minute time frame, but I would like to check a daily chart to see if a condition is met by an indicator, and if so I want to cease trading (ie. if the market is doing something that has proven to make my 5 minute strategy ineffective, I would like to stop trading until normalcy returns).

My issue is that my code stops running the instant I add the line for the new period
 
Code
protected override void Initialize()
      {
Add(PeriodType.Day, 1);
}
Without this line, the strategy runs, but as soon as this is added it stops working. I have not even tried to call this later in the code yet. I have tried changing the period to minute, day, etc and it makes no difference.

Can someone give me any idea what I might be missing that is causing this to kill my script?

Thanks in advance,
jordis

Read about BarsInProgress and it's relation to the Add() method. Your code is now running twice on every tick, once for the main time frame, and another time for the added time frame. That tends to screw up most logic if not segregated by BarsInProgress.

if (BarsInProgress == 0) { ...Main timeframe code}
if (BarsInProgress == 1) { ...Added timeframe code}

Lacking any additional info on the strategy, that would be my guess as to what you are seeing.


Last edited by monpere; December 1st, 2012 at 10:36 AM.
Reply With Quote
 
  #4 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,574 given, 3,982 received

With only this line of code, hard to sat what could be wrong.
Are you checking BarInProgress in OnBarUpdate() ?
You can take a look at the example strategy, @SampleMultiTimeFrame.cs .

Success requires no deodorant! (Sun Tzu)
Reply With Quote
 
  #5 (permalink)
Elite Member
Mobile, Alabama
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Favorite Futures: Stocks
 
Posts: 29 since Sep 2011
Thanks: 6 given, 4 received

Hi,
Thanks for the replies. I have tried using barsinprogress on my strategy, but with no luck. I have also sent my code to ninjatrader support, but have not heard back (i guess maybe they don't work weekends?)

Just to see what mtf is supposed to do, I ran the @SampleMultiTimeFrame.cs strategy on 1, 5, 10, and 60 minute charts... and that didn't even work. The averages plot on the chart, but no trades are ever entered. I have not altered the sample code at all.

Also, I've tried on 2 different computers with the same results. This leads me to believe I am missing some obvious setting somewhere.

Any ideas on why nothing ever happens in these strategies?

ps. I am using imported minute data to backtest, and without the mtf code my strategies work, so I don't think it could be caused by "bad data" or anything like that.

thanks again for the help

Reply With Quote
 
  #6 (permalink)
Elite Member
North Carolina
 
Futures Experience: Advanced
Platform: Ninjatrader
Broker/Data: IQ Feed
Favorite Futures: GC, 6E, CL
 
Posts: 4 since Jan 2010
Thanks: 0 given, 0 received


jordis View Post
Hi,
Thanks for the replies. I have tried using barsinprogress on my strategy, but with no luck. I have also sent my code to ninjatrader support, but have not heard back (i guess maybe they don't work weekends?)

Just to see what mtf is supposed to do, I ran the @SampleMultiTimeFrame.cs strategy on 1, 5, 10, and 60 minute charts... and that didn't even work. The averages plot on the chart, but no trades are ever entered. I have not altered the sample code at all.

Also, I've tried on 2 different computers with the same results. This leads me to believe I am missing some obvious setting somewhere.

Any ideas on why nothing ever happens in these strategies?

ps. I am using imported minute data to backtest, and without the mtf code my strategies work, so I don't think it could be caused by "bad data" or anything like that.

thanks again for the help

1) What datafeed/broker are you connected to in the Control Center ?

2) What account are you running the strategy in (SIM101, etc) ?

3) What error messages (yellow background text) do you see in the LOG tab of the Control Center?

Reply With Quote
 
  #7 (permalink)
Elite Member
Mobile, Alabama
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Favorite Futures: Stocks
 
Posts: 29 since Sep 2011
Thanks: 6 given, 4 received

thanks for the reply.

answers:
1. im not currently connected to a datafeed or broker. all of my backtesting is done on imported data
2. the account is listed as "Backtest." the other options are "Sim101" and "Replay101"
3. under the Log tab, here is everything that I see is in the attached image.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



thanks again for the help

Reply With Quote
 
  #8 (permalink)
Elite Member
Mobile, Alabama
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Favorite Futures: Stocks
 
Posts: 29 since Sep 2011
Thanks: 6 given, 4 received

also, I've tried enabling order tracking in my code, which i can see in the output window when i run single time frame strategies, but when i try to run an mtf strategy the output window is blank as if nothing is being attempted.

don't know if that's helpful or not, but just wanted to put that out there.

Reply With Quote
 
  #9 (permalink)
Elite Member
Mobile, Alabama
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Favorite Futures: Stocks
 
Posts: 29 since Sep 2011
Thanks: 6 given, 4 received

ok, another wrinkle in the problem.

I tried running the sample multiple time frame strategy on a different set of data (daily data, last price, downloaded from Yahoo for a random stock) and it works. However, when I try to use my Forex data it doesnt work.

I could understand this being an issue if the data was bad and didnt work for the single time frame strategies, but all of my strategies work perfectly on this Forex data in a single time frame. Why would adding another time frame cause this data suddenly to stop working?

Reply With Quote
 
  #10 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


I would suggest experimenting by starting with a simple strategy with a simple print statement for each BarsInProgress to get a better idea of what is happening, and what is suppose to happen. Then incrementally add your other code to pinpoint where the problem might be.

Reply With Quote

Reply



futures io > > > > > trouble adding new time frame to strategy

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
Troubleshooting multi time frame strategy jperales NinjaTrader Programming 4 October 9th, 2014 03:21 PM
Multi Time Frame Strategy Cancellation jthom NinjaTrader Programming 2 October 9th, 2014 12:00 PM
Multiple time frame strategy sharing a variable ShruggedAtlas NinjaTrader Programming 7 February 17th, 2012 02:57 PM
Multi-time frame strategy with periods of different size pequemec NinjaTrader Programming 2 February 24th, 2010 01:41 PM


All times are GMT -4. The time now is 10:16 AM.

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-17 in 0.14 seconds with 20 queries on phoenix via your IP 107.20.115.174