Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Code for range break out strategy - (in ninjatrader) Im attempting to write a simple strategy to enter a trade after price breaks the range of a given time period.
Example, if price breaks the high of the 9:00 to 9:30 price range then go long for 1 point... or if price breaks the low of the 9:00 to 9:30 price range, then go short for 1 point...
Lots of sharp people, would appreciate your insights, thanks!
*****************
original question edited for to better articulate the challenge...thanks
When creating a new thread, note which subforum you are in. Here is a short list of suggestions:
- Topic: Anything to do with an Elite indicator -> Subforum: The Elite Circle
- Topic: Looking for an existing indicator, or how-to use an indicator -> Subforum: (the platform)
- Topic: Programmer needing help with non-Elite indicator -> Subforum: (the platform) - Programming
- Topic: Want an indicator created/modified -> Reply to "Want indicator created free" in Elite Circle
- Topic: Vendors (trading rooms, commercial indicators) -> Subforum: Vendors/Product Reviews
- Topic: Discussion of Forex or Currency trading -> Subforum: Forex and Currency Trading
- Topic: Journals of your trading -> Subforum: Trading Journals or Elite Trading Journals
- Topic: General trading related discussions -> Subforum: Traders Hideout
- Topic: Discussion of a trading method -> Subforum: Traders Hideout
- Topic: Automated Trading -> Subforum: Elite Automated Trading
Last, any Elite Member may create more or less any of these topics in The Elite Circle at your own discretion (your support is appreciated).
This is just a short general list and doesn't cover everything. If you are unsure where to create your new thread, just create it in Traders Hideout and a moderator will move it if necessary.
This is the type of flexibility I was adding to NT using the LOM. This can only be done with unmanaged transactions which require a lot of overhead in NT7. The LOM project on futures.io (formerly BMT) is designed to encapsulate that complexity and give very complex transactions with minimal programming effort.
I will bring your attention to 2 functions:
publicvoid SetAutoSLPTTicks(int m_StopLoss, int m_ProfitTarget,int m_PositionNumber)
publicbool GoMarketBracket(int m_SharesTraded,double low,double high,int m_PositionNumber)
Use the first function in LOM to set your automatic SL & PT in Ticks. The 2nd function would be in your main OnBarUpdate () or OnMarketData() functions to set the High & Low brackets you wish to enter. Once the order is filled, LOM will set the SL & PT correctly depending if the Short or Long was entered based upon your bracket.
Here is some simple code that does what you want. It has no stop-loss / profit-targets, and it doesn't display the opening range on the chart, but those are easy to add yourself.
I could be missing something, since others seem to think it isn't possible, but it seems to work for opening an order based on your criteria. Adding a profit target should be as easy as picking the amount away from your entry. I wrote it from the ground up, and I have to profess, I don't know anything about "unmanaged transactions" so tell me if I missed something.
As it is currently written, it will enter the trade, and then in the analyzer, close it at the end of day if you have it set to do so.
For fun... Here it is with a 4 tick Profit Target and a 4 tick Stop Loss. Because it has targets and losses, I have made it so that it only goes long once per day, and short once per day. If you want it to only trade on the first break, change both the "LongTrade" and "ShortTrade" to be just TodaysTrade, and you will get only one trade per day.
Your approach here works, but your OCO bracket is driven by your PC. These are not live orders on the market, but you go Long/Short when you detect the event. You could set this to run per tick to minimize slipage if you have a large movement on one bar.
I think the intent was to have two live StopLimit orders, one in each direction to catch the break out. Not sure, if this works for the person starting the thread it certainly works with those limitations.