Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

New Feature Request : AtmOrder of StartAtmStrategy

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

  • psusen
    replied
    Execute and monitor ATM from NT8 Indicators

    Originally posted by NinjaTrader_JessicaP View Post
    Hello pmaglio,

    This feature is being reviewed by the product management team and has been assigned the following unique tracking ID


    SFT-2513


    Please let us know if there is any other way we can help.
    I am very interested in seeing this feature available in an upcoming release.

    Thank you,
    Peter

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    Hello JerryWar,

    I received your email and will follow up with you through email.

    Leave a comment:


  • JerryWar
    replied
    I have crashed Ninja - Three times today with this strategy. My memory is blowing up.
    I have all other strategies and ATM excluded yet when I just open a strategy window I get a printout that should only occur after the Strategy in loaded. See attached. The thing is once I load the strategy then I get no Subscription updates. Something is real wrong. I don't understand static vars that well and wonder whether all of this is really getting unloaded when I remove the indicator because it is acting like it is not.

    Memory use is with only TWO charts.
    Attached Files

    Leave a comment:


  • JerryWar
    replied
    I excluded all compilations except changed version with Print Statements.
    It does change stop but I get no Account subscriptions it should be generating
    updates if I am subscribed.

    Changed indicator attached.
    Attached Files

    Leave a comment:


  • JerryWar
    replied
    I put print statements in all the subscription events to watch the execution etc.
    No subscription events seem to get triggered.

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    Hello JerryWar,

    Likely you have something in your add-on or strategy that’s subscribing right on startup. I might suggest from within the NS editor, right clicking on suspected strategies/Add-ons, and excluding them from compilation, and restarting Ninja. When you have narrowed down the culprit, you can debug the script. It may be something you have in State.SetDefaults.

    Please let us know if you need further instruction.
    Attached Files

    Leave a comment:


  • JerryWar
    replied
    Alan,
    That was exactly what I was looking. I knew there had to be a better way of picking up the order on Restart . One follow up Question, On Shutdown and Restart of Ninja I would normally assume because of State.Terminated should close any account subscriptions I might have already made. But I made a mistake in programming and did not add a subscription to be delisted in State.Terminated after adding a new one. After restarting Ninja the Subscription seemed to still be there because the code was generating printouts without the strategy loaded. Recovering from a crash that would also be true. So what is the proper way to check for any subscriptions on restart when no order is there ? I cannot find any Subscription methods to check this.

    Thanks
    Last edited by JerryWar; 07-20-2017, 11:49 AM.

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    Hello JerryWar,

    It might be risky to assume because order.GetOwnerStrategy() == null, that you do not have an open position. You may wish to use the logic I added on line 113, that prints the positions in the account, coupled with your order.GetOwnerStrategy == null check, to be more certain you do not have an open position.

    See the attached strategy.

    Please let us know if you have any additional questions or I misunderstood what you are asking.
    Attached Files

    Leave a comment:


  • JerryWar
    replied
    Alan, Awesome, Works as expected. I understand why you had me turn it on after the fact as there would be no order present and generate an error. Here is my question. I have to duplicate the section in State.Dataloaded to find the order when an order is manually entered. What i had done was to subscribe the Account to OnPostionUpdate so when it generated a position it set a static Var to let my Indicator know to start sending over stop Price changes and the indicator would respond back in a similar fashion with the stop price and a change flag. So here is my question. I still need the State.Dataloaded section incase I have to restart Ninja I need for the order to get picked up on restart. How do I tell if there are residing orders . Do I check for order.GetOwnerStrategy() = null and if so I know my position is Flat ?. or is there a better way.

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    Hello JerryWar,

    I’ve modified Jessica’s script demonstrating how to assign an order to an order object, print that orders order ID, and modify the price of that order which was created from an ATM and opened from a superdom.

    Within the foreach loop in State.DataLoaded, I check if the order name is “Stop1”, and if so, I assign that order an order object (stopOrder) as well as print that orders OrderID.

    Within OnBarUpdate, I modify the order object’s stop price and submit that change.

    To test this script, create a ATM template called AtmStrategy, with a stop and profit target of 5 ticks. Connect to the simulated data feed, open a superdom, select the ATM template AtmStrategy, and submit a market order. Then enable the attached strategy in the strategies tab, while an output window is open. You will see the order id printed as well as the stop move back 5 ticks.

    Please let us know if you need further assistance.
    Attached Files
    Last edited by NinjaTrader_AlanP; 07-18-2017, 03:56 PM.

    Leave a comment:


  • JerryWar
    replied
    The problem I am fighting with is the OrderID. In order to use the methods in those print statements you need the orderID. I was able to get the OrderID generated in the Print Statements but If I use that it rejects it as invalid.
    Could you add some could to your example to show getting the proper orderID from an exisiting order and then using it with order.GetOwnerStrategy().AtmStrategyClose . Or is this the problem the original poster was pointing to ?

    Leave a comment:


  • NinjaTrader_JessicaP
    replied
    Thank you for your questions JerryWar. You are correct as to how this strategy works.

    As mentioned, this was intended for educational purposes, not direct use. This code was added to State.DataLoaded simply so it would run exactly once, rather than repeating every bar. I would recommend moving this code to a logic appropriate place inside OnBarUpdate and using it there.

    The code used to create the account is "boilerplate" code, or in other words, code I could easily copy / paste between different scripts that need to reference an account. This was the reason this object was made static. While you can certainly reference this member from other scripts, doing so is your responsibility. So you fully understand why this was made static, there is a design paradigm called "test driven development", and one test for portable code (which this needed to be in order for me to use it in many code examples) is that the object you are creating does not reference any local members. Using the static keyword accomplishes this without fully writing out any tests.

    Leave a comment:


  • JerryWar
    replied
    Jessica, Just to make sure I understand this code. It is run as a strategy but does not generate any orders. What it does is on startup ( state==dataloaded) it looks for an ATM order and picks up on it.

    I took notice that the Account was defined as static. I have two questions

    1) if I wanted to interface from another script to this strategy and access the ATM Methods would I need to do that thru public static vars or methods that both the Strategy and my indicator could see ? What I want to do is change the stops from my indicator initially.

    2) It detects the order in State ==State.Dataloaded which happens when the strategy starts So I would need to generate the same process again if the order was not sitting there already. Is this correct ?

    Thanks
    Jerry

    Leave a comment:


  • NinjaTrader_JessicaP
    replied
    Attached is a code sample that should do something like what you are describing. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.
    Attached Files
    Last edited by NinjaTrader_JessicaP; 07-18-2017, 11:53 AM.

    Leave a comment:


  • JerryWar
    replied
    Jessica,
    Thanks I would appreciate any samples to validate what I have already done.( Filter thru accounts)
    I have gotten to the point where I can pick up the execution and position and hopefully by the EOD I am issuing Account.Change() orders. I was only able to get this far by following some old forum posts, I think you did along with help from Chelsea. My Interest in the members post was that ultimately I would rather be Using ATMstrategy methods to manage an existing manual order. I know this can be done by adding buttons with a script but then in order to use all the order types I want I have to in essence replicate the Dom, What is the sense in that. For now the account lookup method will suffice as long as I get the Account.Change() to work. Once I get the stop and exits working with my indicator I can focus on working on Automated entries with a strategy along with the stop/exit code.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Roman Hrabovskyi, Today, 07:51 AM
0 responses
6 views
0 likes
Last Post Roman Hrabovskyi  
Started by Scotty33, Today, 05:45 AM
1 response
14 views
0 likes
Last Post s.kinra
by s.kinra
 
Started by aaajv, Today, 06:45 AM
0 responses
4 views
0 likes
Last Post aaajv
by aaajv
 
Started by MarkTee, Today, 02:53 AM
0 responses
6 views
0 likes
Last Post MarkTee
by MarkTee
 
Started by TheCatTrader, Yesterday, 04:52 PM
2 responses
15 views
0 likes
Last Post TheCatTrader  
Working...
X