NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 08-17-2007, 10:39 PM   #1
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Smile Prior Bar High Or Low OCO Order

Guys,

I know this has already been done in this forum. Buy I can't find it. I have done all the seraches I know. Can anyone help. I am very new at programming C# but ok at cut and paste by example.

I want to do an OCO order to buy or sell short the prior bar as compared to current bar, only have one position open at a time, and set a profit and stop loss bracket around the trade.

Any help would be appreciated.

Thanking you in advance.

jstockman
jstockman is offline  
Reply With Quote
Old 08-17-2007, 10:56 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Unfortunately we are unable to implement actual strategies for bandwidth reasons. But maybe the community can contribute.

We will enhance the list of sample strategies shortly.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 08-18-2007, 01:29 PM   #3
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Default Bandwidth

Quote:
Originally Posted by NinjaTrader_Dierk View Post
Unfortunately we are unable to implement actual strategies for bandwidth reasons. But maybe the community can contribute.

We will enhance the list of sample strategies shortly.
Dierk,

What do you mean by bandwidth reasons?

jstockman
jstockman is offline  
Reply With Quote
Old 08-18-2007, 01:43 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

It means that our current policy is to provide application level support and are unable to provide support at a level where we provide sample code upon request or analyze user code.

Thanks for understanding.
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-18-2007, 05:11 PM   #5
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Thumbs down

Quote:
Originally Posted by NinjaTrader_Ray View Post
It means that our current policy is to provide application level support and are unable to provide support at a level where we provide sample code upon request or analyze user code.

Thanks for understanding.

Ray,

How do you suggest we get answers then if we can't find it on the forum?

jstockman
jstockman is offline  
Reply With Quote
Old 08-18-2007, 05:27 PM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

You can get answers to product questions in our forum.

We will absolutely provide answers to questions related to the operation of our product. To help in the area of programming logic, we are doing the following:

- Developing a comprehensive reference sample library
- Developing a "NinjaScript" online live training course
- Hiring more NinjaScript support engineers

This is all work in progress and we hope to have these additional resources available to the community sooner than later.

Thanks for understanding.
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-19-2007, 11:51 AM   #7
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Smile

Quote:
Originally Posted by NinjaTrader_Ray View Post
You can get answers to product questions in our forum.

We will absolutely provide answers to questions related to the operation of our product. To help in the area of programming logic, we are doing the following:

- Developing a comprehensive reference sample library
- Developing a "NinjaScript" online live training course
- Hiring more NinjaScript support engineers

This is all work in progress and we hope to have these additional resources available to the community sooner than later.

Thanks for understanding.
Ray,

That gives me future hope. Press On!

jstockman
jstockman is offline  
Reply With Quote
Old 08-19-2007, 11:54 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

jstockman there are two ways to proceed with what you are trying to accomplish. You can use ATM strategies or you can use things like EntriesPerDirection and EntriesHandling to achieve the effect you want.

For the ATM strategy approach:
This link will help you on coding your entries http://www.ninjatrader-support.com/H...egyCreate.html.
This one shows you how to cancel previous orders http://www.ninjatrader-support.com/H...egyActive.html.
This one shows you how to modify previous orders instead of canceling it http://www.ninjatrader-support.com/H...helpguide.html.
With ATM strategy, you create the entry and then you can manually manage the stop/profit targets from within any order entry windows.
Check out the Video library section on ATM strategies on how to maximize its efficiency http://www.ninjatrader-support.com/H...l?VideoLibrary.

For the non-ATM approach:
You can use things like EnterLong/EnterShort with this method. What you want to do in the Initialize() section of your code is add two lines.
Code:
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
Basically what those two lines are doing is forcing NinjaTrader to ignore all additional entry conditions if you already have a position. You can review the exact method of using them with these two links http://www.ninjatrader-support.com/H...Direction.html
http://www.ninjatrader-support.com/H...yHandling.html

Please note that EntriesPerDirection and EntryHandling DO NOT affect ATM strategies. For ATM strategies you might need to add some programming checks to insure you don't enter while you have a position open. I believe you can use something like this to check if you have a position open or not.
Code:
Position.MarketPosition==MarketPosition.Flat
I am not 100% sure if that will work on ATM strategies, but you can give it a try. You can also have Position.MarketPosition checked against MarketPosition.Long and MarketPosition.Short if you have a need for that.

Personally I have not experimented much with the ATM strategy approach, but it might be more suitable if you want to manually manage your positions after your strategy enters them. In the non-ATM approach you will need to manually program ExitLong() and ExitShort() at where you want the profit target and where you want the stop loss to be.

I hope this helps jstockman. If you are still having problems why don't you post up your strategy and I'll take a look and see if I can give you any pointers?
Last edited by NinjaTrader_Josh; 08-19-2007 at 11:58 AM.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-19-2007, 12:17 PM   #9
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Default

uacvax,

Thank-you for the help. I want to take a look at TRO Trillion using this method.

jstockman
Last edited by jstockman; 08-19-2007 at 12:18 PM. Reason: Too much space
jstockman is offline  
Reply With Quote
Old 08-19-2007, 12:38 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

I've only heard about the TRO Trillion strategy. Never really looked deep into it. Please let me know how it goes.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-06-2007, 02:31 PM   #11
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by Josh View Post
jstockman there are two ways to proceed with what you are trying to accomplish. You can use ATM strategies or you can use things like EntriesPerDirection and EntriesHandling to achieve the effect you want.

For the ATM strategy approach:
This link will help you on coding your entries http://www.ninjatrader-support.com/H...egyCreate.html.
This one shows you how to cancel previous orders http://www.ninjatrader-support.com/H...egyActive.html.
This one shows you how to modify previous orders instead of canceling it http://www.ninjatrader-support.com/H...helpguide.html.
With ATM strategy, you create the entry and then you can manually manage the stop/profit targets from within any order entry windows.
Check out the Video library section on ATM strategies on how to maximize its efficiency http://www.ninjatrader-support.com/H...l?VideoLibrary.

For the non-ATM approach:
You can use things like EnterLong/EnterShort with this method. What you want to do in the Initialize() section of your code is add two lines.
Code:
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
Basically what those two lines are doing is forcing NinjaTrader to ignore all additional entry conditions if you already have a position. You can review the exact method of using them with these two links http://www.ninjatrader-support.com/H...Direction.html
http://www.ninjatrader-support.com/H...yHandling.html

Please note that EntriesPerDirection and EntryHandling DO NOT affect ATM strategies. For ATM strategies you might need to add some programming checks to insure you don't enter while you have a position open. I believe you can use something like this to check if you have a position open or not.
Code:
Position.MarketPosition==MarketPosition.Flat
I am not 100% sure if that will work on ATM strategies, but you can give it a try. You can also have Position.MarketPosition checked against MarketPosition.Long and MarketPosition.Short if you have a need for that.

Personally I have not experimented much with the ATM strategy approach, but it might be more suitable if you want to manually manage your positions after your strategy enters them. In the non-ATM approach you will need to manually program ExitLong() and ExitShort() at where you want the profit target and where you want the stop loss to be.

I hope this helps jstockman. If you are still having problems why don't you post up your strategy and I'll take a look and see if I can give you any pointers?

Josh,

Please confirm my thinking.

I can create an ATM strategy using the wizard. When I want engage this ATM strategy I use the above command. (Or is it just the opposite). I create the above strategy and then somehow using the Superdom ( which will show me the trade postion) I manage it manually?

Thanks for the clarification.

jstockman
jstockman is offline  
Reply With Quote
Old 09-06-2007, 04:34 PM   #12
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Are you referring to the NinjaScript Strategy Wizard? I do not believe you can automatically create ATM strategies straight from that wizard, but you can definitely use the wizard to create your strategy and then add in the ATM strategy stuff.

What happens when you run your NinjaScript strategy with ATM strategies coded inside is it will execute orders that you will be able to manually manage through any of NinjaTrader's order management windows (e.g. SuperDOM).
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-06-2007, 07:04 PM   #13
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by Josh View Post
Are you referring to the NinjaScript Strategy Wizard? I do not believe you can automatically create ATM strategies straight from that wizard, but you can definitely use the wizard to create your strategy and then add in the ATM strategy stuff.

What happens when you run your NinjaScript strategy with ATM strategies coded inside is it will execute orders that you will be able to manually manage through any of NinjaTrader's order management windows (e.g. SuperDOM).
Josh,

I get it!

Is there a way around limitations on EntriesPerDirection etc.?

"ATM Strategies operate in real-time only and will not execute on historical data thus they
.Executions resulting from an ATM Strategy that is created from within a NinjaScript
automated strategy will not plot on a chart during real-time operation
.Strategy set up parameters such as EntriesPerDirection, EntryHandling, ExitOnClose do not
apply when calling the
AtmStrategyCreate() method"

jstockman
jstockman is offline  
Reply With Quote
Old 09-06-2007, 11:16 PM   #14
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

What you could try is just pass around a variable that is 1 when you already have an ATM position open and 0 when it is flat. Basically just have an if statement checking if this variable is 1 or 0 and only allow for a new AtmStrategyCreate() when it is 0.

You can use GetAtmStrategyMarketPosition() to determine if you have an ATM strategy position open or not. Just pass along the AtmStrategyId to it and you should be good to go.

http://www.ninjatrader-support.com/H...yPosition.html
Last edited by NinjaTrader_Josh; 09-06-2007 at 11:34 PM.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-08-2007, 01:28 PM   #15
jstockman
Member
 
Join Date: Aug 2007
Location: California
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
Default NinjaScript and ATM Strategy

Josh,

Thank-you for pointing me in the right direction. I have just read the docs in NT regarding this area. Looks pretty straight forward. The stategy I am heading for is found in the Tradestation Forum under Trillion Dollar. Using daily bars I look to go long on first current bar that crosses above prior day high or go short if crosses below prior days low. The trick is to have one position open either long or short depending what broke open first. TRO sets his profit about 5 and stop about 7. It is kind of backwards to what all the books teach. But the stats bear out good percentages for the trade.

I'll keep you posted.

Regards,

jstockman
jstockman is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
1st Hour High/Low pijamatrader Indicator Development 42 07-16-2007 05:31 PM
Pivots and Prior Days OHLC Problem stargazer Charting 13 07-13-2007 07:02 AM
PriorDayOHLC() question about prior session SuzyG General Programming 4 04-29-2007 01:30 PM
Re: Prior Day OHLC Indicator Antraman Indicator Development 12 06-07-2006 12:31 AM
Prior Day OHLC Indicator (Download) Version 5 Only NinjaTrader_Ray Indicator Development 1 05-19-2006 02:18 AM


All times are GMT -6. The time now is 04:44 PM.