![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Location: Castle Pines, Co
Posts: 621
Thanks: 1
Thanked 2 times in 2 posts
|
I want to trigger an order if two different TimeFrames agree ie: 5 min shows a buy and 1 min shows a buy then buy..
Can I do this with the BarsInProgress? |
|
|
|
|
|
#2 |
|
Senior Member
|
1st : Code your strategy to be placed on the lowest time frame ( 1Min )
2nd : On Initialize() add " Add(PeriodType.Minute,5); 3rd : On OnBarUpdate() is going to run each time a bar closes on both timeframes You can check that by if (BarsInProgress == 0) then 1Min bar is triggering Then u can check a condition ( like SMA(50)[0] ) on both timeframes by SMA(BarsArray[1], 20)[0] // for the 5 Min SMA(Close, 20)[0] // fro the 1 min |
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello gg80108,
Thank you for your post. You need to use a combination of BarsInProgress, BarsArray, and Closes, Opens, Highs, Lows for this. The snippet below buys when Close is greater than the 14 period SMA for the two different series. The BarsInProgress == 0 check will ensure that this is only performed during updates to the primary series but the BarsArray and Closes properties tell it to look at values in the secondary series. Code:
if (BarsInProgress == 0)
{
if(Close[0] > SMA(Close, 14)[0] && Closes[1][0] > SMA (BarsArray[1], 14)[0])
EnterLong();
}
http://www.ninjatrader-support.com/H...struments.html
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Excellent. Thanks for sharing, pmaglio!
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Aug 2010
Location: Locust Valley, NY
Posts: 102
Thanks: 0
Thanked 0 times in 0 posts
|
Interesting thread. I'm still stuck though.
I'm trying to do a two step entry. Run a handful of proprietary indicators on a longer time frame, eg 50 ticks. If those conditions are met (a bunch of them), then run some proprietary indicators on shorter time frame, eg 5 tck bars, but only for about 2 periods of the longer timer frame. Any assistance would be helpful (v 6.5) Steve |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Steve,
Thank you for your post. You can see a sample multi time frame strategy by clicking Tools > Edit NinjaScript > Strategy > Sample Multitime frame. If you only want to evaluate your secondary series after the primary series is true, you can set and check bool values to code the sequence you're looking for. if (firstSeriesConditions) evaluateSecondSeriesNow = true; if (evaluateSecondSeriesNow && secondSeriesConditions) //place orders here Someplace later you would reset the bool values - possibly when flat.
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multi Time Frame Strateg | toptrader | General Programming | 13 | 01-20-2010 07:08 AM |
| Multi-Instrument Multi-Time frame strategy | Shansen | Strategy Development | 1 | 12-28-2009 06:09 AM |
| Multi-time frame strategy - Longer-term real-time calculations | Shansen | Strategy Development | 1 | 04-19-2009 06:36 AM |
| Multi Time Frame/Multi Instrument? | GreenTrade | Strategy Development | 3 | 01-14-2008 02:24 PM |
| Multi-time frame | scjohn | Strategy Development | 1 | 06-06-2007 07:20 PM |