Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Prior Bar High Or Low OCO Order

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_Ray
    replied
    Thanks for pointing out the typo in the DOC.

    Leave a comment:


  • jstockman
    replied
    Originally posted by Josh View Post
    Hi jstockman

    Your error is because you capitalized some of the letters. It is not "GetATMStrategyUniqueId()" it is "GetAtmStrategyUniqueId()". The "tm" in "Atm" are not capitalized.

    The OnBarUpdate() is the section in which you want to put your logic. You don't put it on every entry condition. Whatever is inside the OnBarUpdate() is the algorithm that NinjaTrader will run through every time a bar is updated. It will start from the top and run through till the end of OnBarUpdate(). Does that make sense?
    Josh,

    Thank-you. I guess NT needs to clean up its docs. This is a copy job from the AtmStrategyCreate() under the help menu

    // Check for valid condition and create an ATM Strategy
    if (Close[0] > SMA(20)[0])
    AtmStrategyCreate(Action.Buy, OrderType.Market, 0, 0,
    TimeInForce.Day, GetATMStrategyUniqueId(), "MyTemplate",
    GetAtmStrategyUniqueId());


    By the by, the code did compile. Thank-you again

    jstockman

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Hi jstockman

    Your error is because you capitalized some of the letters. It is not "GetATMStrategyUniqueId()" it is "GetAtmStrategyUniqueId()". The "tm" in "Atm" are not capitalized.

    The OnBarUpdate() is the section in which you want to put your logic. You don't put it on every entry condition. Whatever is inside the OnBarUpdate() is the algorithm that NinjaTrader will run through every time a bar is updated. It will start from the top and run through till the end of OnBarUpdate(). Does that make sense?

    Leave a comment:


  • jstockman
    replied
    Compilation Errors

    Josh,

    As you have guessed I am a newbie at Ninja Script. I do have some experience on TradeStation Easy Language. None with C#. Help!


    I am getting compilation errors on "GetATMStrategyUniqueId". When I go to the docs for this thing it says I am suppose to

    Examples
    protected override void OnBarUpdate()

    { string orderId }.

    I put this into the attached an with "Unknown" for the string. I got more errors.

    Query

    Do I have to add Protected override void OnBarUpdate() on each command or just the section dealing with ATM strategies?

    What is this unique ID and how do I get rid of these errors.

    Thanking you in advance.

    jstockman
    Attached Files

    Leave a comment:


  • jstockman
    replied
    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

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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.

    Last edited by NinjaTrader_JoshP; 09-06-2007, 11:34 PM.

    Leave a comment:


  • jstockman
    replied
    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

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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).

    Leave a comment:


  • jstockman
    replied
    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


    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

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    I've only heard about the TRO Trillion strategy. Never really looked deep into it. Please let me know how it goes.

    Leave a comment:


  • jstockman
    replied
    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, 12:18 PM. Reason: Too much space

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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


    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_JoshP; 08-19-2007, 11:58 AM.

    Leave a comment:


  • jstockman
    replied
    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

    Leave a comment:


  • NinjaTrader_Ray
    replied
    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.

    Leave a comment:


  • jstockman
    replied
    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

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by kevinenergy, 02-17-2023, 12:42 PM
122 responses
2,878 views
1 like
Last Post Lancer
by Lancer
 
Started by rayyyu12, Today, 03:59 PM
0 responses
4 views
0 likes
Last Post rayyyu12  
Started by calmcosmia, Today, 03:07 PM
4 responses
13 views
0 likes
Last Post calmcosmia  
Started by Tim-c, Today, 02:34 PM
1 response
7 views
0 likes
Last Post NinjaTrader_Jesse  
Started by idangre, 12-08-2016, 11:37 AM
11 responses
1,285 views
0 likes
Last Post gkadokg
by gkadokg
 
Working...
X