Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TDAmeritrade account position

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

    TDAmeritrade account position

    In the tips section, there is a stern warning on the difference between the account position and strategy position. This sounds pretty important, but not enough detail is provided for me to understand what exactly I should do. So here are some followup questions (assume all is in the context of a TDAmeritrade account):
    1. Suppose that my Ameritrade account has no positions in any symbol. I start an automated strategy at 11Am EST (after the trading session started). I understand that the strategy would be executed on all the previous bars of the day and if it had a strategy position on some stock at the time I start it - then there is no way for it to know that the account actually has no position in the stock. When the strategy attempts to close the position, I would end up with an opposite position in my account. Is this correct?
    2. Somewhat similar scenario. I can an account with no positions. I start an automated strategy the night before, after the previous day trading session closed (say 9PM EST). Suppose that the strategy only places positions during trading hours. Suppose as well, that IF the strategy would have ran itself against all the previous day's bars (the day that I started it in) it would have had a position on a stock at the end of the day. The question is, would the strategy actually have a strategy position at the beginning of the next session (the following day), or would it have "known" not to run itself when i start it after the trading session?
    3. Same scenario, but now I start the strategy on a weekend, but had the strategy been ran on the previous Friday it would have had a position. Am i safe in this situation?
    4. Is there any way in the API to find out what my account position is in a symbol (rather than the strategy position?)
    5. Is there any way in the API to find out whether I am running live or in simulation, or against what account I am running?

    Bottom line - I am trying to understand what exactly is a safe strategy deployment procedure when using NJ with TDAmeritrade such that no discrepancies occur between the strategy positions and account positions. These kinds of discrepancies can wreck the best strategies possible (as their actual actions do not match what the strategy thinks it did). For me not understanding this fully is a show stopper in using NJ for strategy automation... The tip is useful but much more detail is needed.

    #2
    Hello,

    Thanks for the forum post.

    Answers completed below:

    .
    1. Suppose that my Ameritrade account has no positions in any symbol. I start an automated strategy at 11Am EST (after the trading session started). I understand that the strategy would be executed on all the previous bars of the day and if it had a strategy position on some stock at the time I start it - then there is no way for it to know that the account actually has no position in the stock. When the strategy attempts to close the position, I would end up with an opposite position in my account. Is this correct?

    .

    Correct if you are using the settings under control center->tools->options->strategies tab->Ninjascript subtab-> Immediately submit live working historical orders. If using wait unitl flat before executing live the strategy would be in a yellow state until the strategy returned back to flat before submitting any live orders.



    .
    1. Somewhat similar scenario. I can an account with no positions. I start an automated strategy the night before, after the previous day trading session closed (say 9PM EST). Suppose that the strategy only places positions during trading hours. Suppose as well, that IF the strategy would have ran itself against all the previous day's bars (the day that I started it in) it would have had a position on a stock at the end of the day. The question is, would the strategy actually have a strategy position at the beginning of the next session (the following day), or would it have "known" not to run itself when i start it after the trading session?

    .

    It would carry a position over from the next day if you do not have code in place to close the trade out at the end of the day or using the setting when you run the strategy Exit On Close.




    .
    1. Same scenario, but now I start the strategy on a weekend, but had the strategy been ran on the previous Friday it would have had a position. Am i safe in this situation?

    .

    Same applied above. The strategy will always work exactly as you code it. If coded to hold over the weekend it will hold over the weekend.


    .
    1. Is there any way in the API to find out what my account position is in a symbol (rather than the strategy position?)

    .


    Unfortunately this is not possible and there is no concept of this in NinjaTrader.



    .
    1. Is there any way in the API to find out whether I am running live or in simulation, or against what account I am running?

    .
    You can only check with if (Historical) if you are running on historical data vs live data. There is no supported way to detect account number unfortunately. There is the unsupported method you could use: Account.Name

    -Brett

    Comment


      #3
      Thanks. This helps.
      Perhaps some of the clarifications should be included in the tips section. This is a very important behavior.
      I will read further on wait until flat - as it sounds like the way to go in this case.

      One more clarification I need: my understanding is that the strategy will go to the beginning of the current trading day and will start computing from there, but won't go to before that. Is that correct, or is it like an indicator, where it will go to the beginning of the displayed chart and start computing from there?

      Comment


        #4
        It is like an indicator and will start on the first bar of the chart to calculate and move forward from there running your OnBarUpdate() logic.

        -Brett

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frankthearm, Today, 09:08 AM
        5 responses
        10 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        43 views
        0 likes
        Last Post jeronymite  
        Started by yertle, Today, 08:38 AM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by adeelshahzad, Today, 03:54 AM
        3 responses
        18 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by bill2023, Yesterday, 08:51 AM
        6 responses
        27 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X