• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Start behavior

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

  • tonynt
    replied
    Hello Kate,

    thank you for your reply. This sounds logically to help with this topic. And I agree to set a bool to allow an entry or not. But I have not found how I can cycle through to have eg (in words) "if working stoporder ES" {noentry==true;} instead of the printing statement.

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello tonynt,

    Thank you for your reply.

    The pages on Orders (that I linked in my previous post) and Account (https://ninjatrader.com/support/help...ount_class.htm) have examples of getting the account and then cycling through orders. You could check the returned order objects for the order type and instrument.

    Here's the example from the Orders page fleshed out a little bit:

    Code:
            private Account myAccount;
    
            protected override void OnStateChange()
            {
              if (State == State.SetDefaults)
              {
                  // Initialize myAccount
                  // Find our Sim101 account
                    lock (Account.All)
                          myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
    
                    if (myAccount != null)
                    {
                          // Print some information about our account using the AccountItem indexer
                          Print(string.Format("Account Name: {0} Connection Name: {1} Cash Value {2}",
                              myAccount.Name,
                              myAccount.Connection.Options.Name,
                              myAccount.Get(AccountItem.CashValue, Currency.UsDollar)
                              ));
    
                          // Subscribe to events. Remember to unsubscribe with -= when you are done
                          myAccount.AccountItemUpdate += OnAccountItemUpdate;
    
                      }
                }
            }
    
    
            private void OnAccountItemUpdate(object sender, AccountItemEventArgs e)
            {
              // Print the name and order action of each order processed on the account
              foreach (Order order in myAccount.Orders)
              {
                  Print(String.Format("Order placed: {0} - {1} - {2}", order.OrderType, order.OrderState, order.Instrument));
              }
            }
    As we see above, you can cycle through using the foreach and then you can perform whatever logic you need to based on whether or not you found an order that is a stop - probably be easiest to set a bool to true if you find one that you can then use to control your entry.

    However, it would be far less complicated to simply combine the logic into a single strategy.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • tonynt
    replied
    Hello,

    thank you for your reply. "That being said you could look into using the Account class to get the orders on the account and then cycle through those checking the instrument of each order:" I have no idea how this to work. From the link I do not understand how I can check if there is stoporder on the instrument (this is how I understand your reply and this is logically and a good idea... if there is no stop in ES on the account (= not in a trade) then do...

    Can you give me please a snippet or one line or a sample?

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello tonynt,

    Thank you for your reply.

    This would not be advisable as you run the risk of a position update that hasn't yet been received by NinjaTrader for one strategy making the other strategy think there's not a position in the works, and the second strategy submitting a entry anyway since the first has not received back a position update. If you combine the strategies, that risk is significantly mitigated as the strategy is managing all aspects of the position.

    That being said you could look into using the Account class to get the orders on the account and then cycle through those checking the instrument of each order:

    https://ninjatrader.com/support/help...rs_account.htm

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • tonynt
    replied
    Hello Kate,

    thank you vor your reply. How can I check in a script-strategy if there is no current position/trade on the same account and this instrument. So that eg a long (or short) trade in NQ should not prevent the ES-script to do an entry. But if there is a position/trade in ES then we do not want to trigger an entry from the script.

    So this would be the best way to avoid the issues and not having all conditions in one script.

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello tonynt,

    Thank you for your reply.

    Signal names only are used internally to the strategy that is placing them to match orders. If you have two strategies running, it would be possible for Strategy A's position to be closed by Strategy B's stop and vice versa, creating quite a mess in your Trade Performance report. It would be advised to combine all logic into a single large strategy so the strategy can be aware of all positions.

    The intent of account synchronization is to force the account position to a flat position for your strategy to begin from and it assumes it's the only strategy you are using.

    Immediately submit will ignore the account position when used without Synchronize account and will just immediately submit an order to match what your strategy position it thinks it should be in.

    All in all, again, we cannot recommend running multiple strategies on the same account/instrument position simultaneously regardless of start behavior chosen.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • tonynt
    replied
    Hello Kate,

    let me ask different please (and sorry for bothering but as english is not my main language sometimes like now I´m not sure if I got your reply 100%).

    Back to the beginning: when I do not trade same time long and short is it then necessary to use "WaitUntilFlatSynchronizeAccount"? In other words when I would have an account for long trades and an account for short trades then I could run more than one long script on the longaccount and more than one script on the shortaccount?
    I use in the scripts proper names like "entryOrderLvol1a=EnterLongLimit(4,true,1,GetCurre ntAsk(), "Lvol1a");" eg in script "Lvol". So I know in orderstab which strategy has triggered and from this I thought also there should not be an impact from one script to the other? Yes/No?

    What would be the problem then when using immediatelysubmit (I mean when not trading long and short on one account)?

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello NT-Roland,

    Thank you for your reply.

    This is why we suggest consolidating the logic from multiple strategies that you would run on the same account into one large strategy that would control the entire position, which would satisfy the "only trade the resulting net instrument position externally" - you could use the logic from both strategies to calculate what the account position should be and place trades based on that. It's only if the logic of the strategies cannot be somehow combined (for example, if one is a third party strategy where you cannot access the code) that we would recommend using multiple accounts.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • NT-Roland
    replied
    Hi,
    One of the serious limitations of Ninja. To boost the number of accounts as workaround implies to "lock in" some excess margin on each of them.
    You could consider adding a virtual account in NinjaTrader consolidating all positions from all strategies and matching the net instrument positions on this virtual account against the respective net instrument position at the broker account. Or even better, take this one step further and only trade the resulting net instrument position externally, greatly saving on commission and slippage.
    Only if a strategy is out of sync with its balance on the virtual account (identified via Order IDs), it would be adjusted. All other strategies and positions on the virtual account would be left untouched.
    NT-Roland

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello tonynt,

    Thank you for your reply.

    We would not recommend running multiple strategies on the same instrument/account combo in NinjaTrader 7 either.

    If you need to run multiple strategies on the same account/instrument combination, we would recommend combining the logic of the strategies into one large strategy so the strategy can fully handle all positions. There are some cases in which traders intend for their strategies to contradict each other and simply view the account PnL instead of the strategy PnL, so the ability to do so has been left, however, it can be very tricky and again, not recommended as too many things may go wrong.

    Running a strategy using Wait Until Flat, Synchronize account will throw off any other strategies on that instrument/account combination that already had positions prior. You would not be able to use the synchronize account feature when doing so. You would need to start a strategy using Wait Until Flat if other strategies are already in positions instead to keep it from submitting the Synchronization order if you wanted to run multiple strategies at once.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • tonynt
    replied
    Hello Kate,

    thank you for your reply and your explanation.

    My work for years is for using strategies for different market situation. One can not catch all with one "holy grail".

    I have had in NT7 for live trading different strategies and there was not such a problem.

    Can´t this problems be avoided in NT8? With another start behavior? Referring to your sample I know that one can not be long and short same time.

    My question is referring to different strategies in same direction. Isnt it possible to run same time 2 long scripts and each triggers an entry? Can´t we ignore the marketposition so that the long script is doing what it should do from coding, no matter if another long script is in a trade?

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_Kate
    replied

    Hello Tony,

    Thank you for your reply.

    It is not recommended to run more than one strategy on the same instrument and account combination at the same time.

    This can result in scenarios like you're seeing when using Wait Until Flat, Synchronize account.

    The issue is that strategies are only aware of their own calculated position — they don't know what the other strategy or strategies on the account are doing.

    Let's look at an example of why running multiple strategies on the same account and instrument combo isn't a good idea:

    Say we have two strategies, Strategy A and Strategy B. We start them at the same time while the account is flat, so we're not worried about synchronization.

    Strategy A places an order for 8 long. Strategy B then places an order for 5 short. Strategy A will think it is in an 8 long position, Strategy B will think it is in a 5 short position, but the actual Account position would be 3 long, meaning that your PNL isn't what you think it is.

    In your case, Strategy A has a position already, and then you start Strategy B using Wait until Flat, Synchronize account. Strategy B sees the open position from Strategy A, and sends the synchronization order to bring your account position to where Strategy B thinks it should be, thus throwing off Strategy A.

    I would suggest if you want to run different strategies for the same instrument, that you create a new sim account to run each strategy on. Same would go for live, if you want to run more than one strategy on the same instrument, we would suggest you trade them on different accounts.

    Here's a link to our help guide on creating multiple sim accounts:

    https://ninjatrader.com/support/help...n_accounts.htm

    For additional live accounts you would need to consult your broker.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • tonynt
    replied
    Hello Kate,

    thank you for your reply. I sent the log and trace file.

    Can not be that one can not run 2 strategies(?)
    One can not have one account for each strategy.

    Thank you!

    Best regards
    Tony
    Last edited by tonynt; 05-08-2020, 12:25 PM. Reason: typo

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello tonynt,

    Thank you for your reply.

    Are you running any other strategies on the same account and instrument when you start up this strategy?

    I would need to take a look at your log and trace files to see what may have occurred.

    You can do this by going to the Control Center-> Help-> Email Support

    Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

    Please reference the following ticket number in the body of the email: 2428641 ATTN Kate W.

    ​Thanks in advance; I look forward to assisting you further.

    Leave a comment:


  • tonynt
    replied
    Hello Kate,

    it occurs again that after an entry there was "synchronize". Please see the attached screenshot from executions tab.

    I have in the code StartBehavior.WaitUntilFlatSynchronizeAccount;

    And I have done entries only from script strategies, but not with ATM.

    The close is manually from me then because there was a naked long.


    ??

    Thank you!
    Tony
    Attached Files
    Last edited by tonynt; 05-08-2020, 08:30 AM. Reason: add info

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by brownsfan019, Today, 06:56 AM
0 responses
1 view
0 likes
Last Post brownsfan019  
Started by webus, Yesterday, 03:34 PM
1 response
18 views
0 likes
Last Post NinjaTrader_PaulH  
Started by Grantx, Today, 06:46 AM
0 responses
4 views
0 likes
Last Post Grantx
by Grantx
 
Started by JBTrader2005, Yesterday, 03:57 PM
1 response
17 views
0 likes
Last Post NinjaTrader_PaulH  
Started by bippo, Today, 06:25 AM
2 responses
9 views
0 likes
Last Post bippo
by bippo
 
Working...
X