• 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

Creating a sync method

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

  • NinjaTrader_Kate
    replied
    Hello pstrusi,

    Thank you for your reply.

    I believe I may have misread question six. While you can submit an order from within OnConnectionStatus(), this would still affect your strategy position. You would need to manually sync the strategy by submitting a manual order to bring your Strategy and Account positions to be the same.

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

    Leave a comment:


  • pstrusi
    replied
    Hi Kate,
    I appreciate your attention and response to my questions.

    I have only a doubt in regards to question 6. Let's suppose that within OnConnectionStatus() , I detect that my actual Strategy Position is flat, BUT the AccountPosition, somehow is not. If I submit a reconciliatory order to flatten my Account Position, won't that action create a non flat Strategy Position now?

    Once again, thank you

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello ptrusi,

    Thank you for your post.

    1 and 2: As far as order goes, most of the processing is event based, so the methods are fired when an event happens that impacts that method. So, OnConnectionStatus() most likely won't be triggered until a connection issue occurs. Initialize() OnStartUp() will go first, but after that it's dependent on what events occur. After a disconnect/reconnect event, OnConnectionStatus() fires, then the next OBU in my testing.

    3. All of this is correct.

    4. I select in the Strategies-tab the option: Recalculate on ConnectionLoss, once the connection is back on, what method should go first: OnBarUpdate() cause it's recalculating OR OnConnectionStatus() because of the recovered connection? This is key to me in order to create a sync method.

    5. In this case your account will not be in sync with your strategy and will remain out of sync.

    6. You should be able to submit an order from any event method. You could submit one directly from OnConnectionStatus if you like.

    7. There is no way, supported or unsupported, that we are aware of to change the internal values for StrategyPostion or StrategyPosition.Quantity.

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

    Leave a comment:


  • pstrusi
    started a topic Creating a sync method

    Creating a sync method

    I'm trying to create a method that helps me in the sync process of NT, not only when starting a strategy but also when long disconnections occur. In order to set the right logic flow, I need to understand some details on how it runs. Here some questions:

    1. When a strategy is starting, the work logic order of main methods is:
    Initialize() OnStartUp() OnConnectionStatus() OnBarUpdate() then OnPositionUpdate( ) and others ?

    2. When a running strategy is reconnecting after a connection loss, is it :
    OnConnectionStatus() OnPositionUpdate( ) OnBarUpdate() then others ?

    3. If I select in the Strategies-tab the option: KeepRunning on ConnectionLoss, once the connection is recovered, I understand that the Strategy won't recalculate anything but only will process the new tick coming, is it not? So I assume that any previous Strategy Position will continue to be the same. But if I select in the Strategies-tab the option: Recalculate on ConnectionLoss, it will mean that once the connection is back on, then the Strategy will use the historical data to calculate the right Strategy Position, right? So, if I use within my code: if ( historical ) { returns;} then any recalculation would always be a FLAT Strategy Position, right?

    4. I select in the Strategies-tab the option: Recalculate on ConnectionLoss, once the connection is back on, what method should go first: OnBarUpdate() cause it's recalculating OR OnConnectionStatus() because of the recovered connection? This is key to me in order to create a sync method.

    5. If I set to sync at initial startup Account Positions with Immediately submit live working historical orders, but I use in the code:
    if ( historical ) { returns;}
    then my Strategy Position will be flat when the first live tick data comes, but what would it happen if my broker's account has actually an open position, will NT submit a reconciliatory order to sync positions with that first tick of live data ? or since there's not any longer historical data, not reconciliatory orders will be submitted any more?

    6. Is there any way that I was able to submit direct orders to my broker's account from any method other than OnBarUpdate(), such as protected override void OnConnectionStatus( ) in order to affect only my broker's account leaving out of effect the Strategy position?

    7. Is there any unsupported way to change the internal variables values for StrategyPosition OR Strategy Position.Quantity ?



    Thanks
    Last edited by pstrusi; 09-30-2019, 06:10 AM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Aporshnev, Today, 05:56 PM
0 responses
4 views
0 likes
Last Post Aporshnev  
Started by aslane, Today, 05:46 PM
0 responses
5 views
0 likes
Last Post aslane
by aslane
 
Started by Aporshnev, Today, 04:31 PM
1 response
7 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by tradykat, Yesterday, 05:09 PM
7 responses
35 views
0 likes
Last Post NT-Roland  
Started by PLeary, Today, 03:09 PM
2 responses
22 views
0 likes
Last Post PLeary
by PLeary
 
Working...
X