Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to make double check to strateg vs. account position due to bid/ask dynamics?

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

    How to make double check to strateg vs. account position due to bid/ask dynamics?

    Hello,

    Due to Bid/Ask dynamics sometimes it gets me out of a position when it shouldn't, and then if I disable/enable the strategy because of overnight/closing ninja, I get a mismatch in strategy position vs. account position, because then he calculate the position in historical terms.
    the result of that is: when he tries to get me out, he gets me out in the old position for example 200, and now I am in 100 position, so I will now be short 100.

    In short, I want to do a double check whenever he exit a trade, to make sure the position is equal to the account position.

    I am using for the stop quantity the variable: Position.Quantity , which now I know could be wrong due to historical/real-time differences.

    How can I do double check on Position.Quantity? + where should I put it? (in executionupdate?)

    something like: if (Position.Quantity > Account.Quantity) then exit with Account.quantity.

    the strategy is Long ONLY, so I know for sure that I will never want to be Short somehow.

    If you thought about this problem already, will appreciate the solution, thanks in advance!


    #2
    Hello zoharcho,

    One possible way around this would be to reference the account position instead of the strategy position. You could do this as a check in OnBarUpdate to determine what to do when the strategy starts up. For example if the account already has a position you could avoid submitting historical entries/exits and then just wait in real time until the position is closed. If you are relying on the strategy to exit the position that could also be used to delegate that situation once you are in realtime.

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

    I would not likely suggest trying to combine working with historical orders or trying to match quantities with using the live account position, it would be easiest to use this from OnBarUpdate to just determine how to start the strategies logic. An example would be if there is no position use one set of logic to execute normally, if there is a position use a separate set of logic to exit or wait then resume the normal logic again.

    I look forward to being of further assistance.


    JesseNinjaTrader Customer Service

    Comment


      #3
      Just what I needed! I didnt know there is a variable named: PositionAccount.Quantity

      wanted to use it, thank you for letting me know. thank you, I think it will solve the problem.

      thanks Jesse.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pyraxic, Yesterday, 06:22 PM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by b16_aln, Today, 06:12 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by Icus1, Yesterday, 06:26 PM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by patricia70, Today, 03:57 AM
      2 responses
      9 views
      0 likes
      Last Post patricia70  
      Started by saeed, Today, 06:09 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Dennis  
      Working...
      X