How to create strategy that looks at multiple bars? - futures io
futures io futures trading



How to create strategy that looks at multiple bars?


Discussion in NinjaTrader

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

How to create strategy that looks at multiple bars?

  #1 (permalink)
Las Vegas, NV
 
Experience: Beginner
Platform: NinjaTrader 8
Trading: Emini ES
 
Posts: 3 since May 2020
Thanks: 1 given, 0 received

How to create strategy that looks at multiple bars?

I have some basic programming experience but am new to NinjaScript and NinjaTrader.

I would like to create a strategy that executes when conditions across multiple bars are met. For example, look for swing high, then if next bar opens at or below previous bar and closes at certain point, isSecondBarCondition = true and check next bar for certain conditions, etc.

I'm struggling to figure out how to do this. The NinjaTrader help file only provides limited information on syntax, and I can't find many other resources. The strategy builder only seems to be able to handle basic conditions and I have no idea how to approach this.

My guess is when scripting I need to create an on state event that looks back x number of bars, and use several if conditions to check each subsequent bar and use booleans to manage which conditions are true.

Is there a more comprehensive resource to learn NinjaScript thoroughly so I can teach myself how to do this? I may just have to pay someone to do it for me, but I would really prefer to learn it myself so I can develop my skills. I just can't find any way to learn this platform.

Is there some resource I'm overlooking or a course somewhere, or if not how can I become proficient in NinjaScript? Is it just a matter of knowing C# and memorizing the reference material?

Or is there a course that would walk me through creating complex strategies so I can develop my abilities?

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
 
 
  #2 (permalink)
Orange County, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
 
Posts: 10 since Sep 2018
Thanks: 2 given, 7 received

Having recently started experimenting with the Strategy Builder myself, I totally relate to what you're experiencing. But there are ways to get to what you want to do. My approach with SB is how I approach other projects whether they are programming projects or home improvement :-). Start small and build on it as you go and gain more experience. But I agree with you that there is no easy primer/course you can read to walk you through how to get started. Or at least, I haven't found one yet.

Having said that, to address your specific example, what you can do is define a Custom Series under Additional Data in SB. This will hold your state based on your swing high/low criteria or any other criteria you're looking at. Then you can use this in the next cycle to combine with other conditions to make a decision on what action to take. You can look back at the state of your Custom Series (or any other data series for that matter) for as many bars as you wish. There is probably functionality in SB to do majority of what you need, you just need to find it out of the haystack - so to speak. It seems a bit clunky, limited and non-intuitive at first (especially if you're a programmer), but as you spend some time fiddling with it and figuring things out, you start to see how it works and how to implement your strategy with the seemingly awkward interface.

One thing you should feel free to utilize is the Ninja Platform Support email. I find the support staff at Ninja very knowledgeable, courteous and prompt. Any time I can't find the answer in the online help, they're able to point me to a resource or help me with code snippets. Sometimes the exact answer you're looking for is in the response to another support case and they point you to it. This same exact thing happened to me last week with a question I had. I wish they would do a better job of incorporating that scattered knowledge back into the help pages. But at least you have a path to get to that knowledge through support.

Hope this helps.

Reply With Quote
The following user says Thank You to sg72 for this post:
 
  #3 (permalink)
Las Vegas, NV
 
Experience: Beginner
Platform: NinjaTrader 8
Trading: Emini ES
 
Posts: 3 since May 2020
Thanks: 1 given, 0 received



sg72 View Post
Having recently started experimenting with the Strategy Builder myself, I totally relate to what you're experiencing. But there are ways to get to what you want to do. My approach with SB is how I approach other projects whether they are programming projects or home improvement :-). Start small and build on it as you go and gain more experience. But I agree with you that there is no easy primer/course you can read to walk you through how to get started. Or at least, I haven't found one yet.

Having said that, to address your specific example, what you can do is define a Custom Series under Additional Data in SB. This will hold your state based on your swing high/low criteria or any other criteria you're looking at. Then you can use this in the next cycle to combine with other conditions to make a decision on what action to take. You can look back at the state of your Custom Series (or any other data series for that matter) for as many bars as you wish. There is probably functionality in SB to do majority of what you need, you just need to find it out of the haystack - so to speak. It seems a bit clunky, limited and non-intuitive at first (especially if you're a programmer), but as you spend some time fiddling with it and figuring things out, you start to see how it works and how to implement your strategy with the seemingly awkward interface.

One thing you should feel free to utilize is the Ninja Platform Support email. I find the support staff at Ninja very knowledgeable, courteous and prompt. Any time I can't find the answer in the online help, they're able to point me to a resource or help me with code snippets. Sometimes the exact answer you're looking for is in the response to another support case and they point you to it. This same exact thing happened to me last week with a question I had. I wish they would do a better job of incorporating that scattered knowledge back into the help pages. But at least you have a path to get to that knowledge through support.

Hope this helps.

Thank you so much for the info. That will definitely help me get started, thanks for the help!

Reply With Quote
 
  #4 (permalink)
Uxbridge UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 7 since Sep 2012
Thanks: 2 given, 9 received

I don't know much about the Strategy Builder, but if you are writing a script the current bar is refered to as [0] the previous bar as [1] and so on back to the first bar in the chart.
You can refer to the different prices within each bar, each is a double value, so you could write -

double someValue = (Open[0] + Close[3] - High[299]) * Low[1]; // But make sure the chart has at least 298 bars.
Or maybe just

double currentHigh = High[0];

High, Low, Open, Close above are series objects. You could also look at some examples.

Reply With Quote



futures io Trading Community Platforms and Indicators NinjaTrader > How to create strategy that looks at multiple bars?




Upcoming Webinars and Events
 

Understanding Order Flow Stop Runs & Icebergs w/Bookmap

May 28
 

Free BloodHound Licenses to everyone!

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