• 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

Strategy donīt work in live trading but in Historical and Strategy analyzer

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

    Strategy donīt work in live trading but in Historical and Strategy analyzer

    Hello,

    My strategy donīt work in live trading but do historical trades and work in the strategyanalyzer.

    Also I wonder how the strategy can do trades in the past.

    Thank you very much.

    #2
    Hello Uregon,

    Thanks for your post.

    Please make sure the strategy is not waiting for its virtual position to be closed if you are using the WaitUntilFlat Start Behavior. (Check the Strategies tab of the Control Center and see if the strategy is yellow/orange.) I have included some information on Start Behaviors and the difference between strategy and account positions in this post.

    If this is not the case and the strategy is gray, then I would suggest checking for errors in the log tab of the Control Center to see if the strategy has errored out.

    If the strategy is green and is not taking trades, the strategy is running but the logic is not allowing it to place trades. Debugging steps should then be taken at this point.

    To answer your question about the strategy doing trades in the past, the strategy will show you which trades it would have made when it processes historical data when we enable it, or when we run a backtest.

    Information on Start Behaviors

    When a strategy is enabled, it processes historical data to determine trades that the strategy would have made on the data that is already on the PC/chart and to determine what position the strategy is in. (Strategy positions are separate from actual Account positions.) If the strategy calculates that is in a virtual position when it transitions to processing realtime data, the strategy's Start Behavior may waiting until this position becomes flat before orders are allowed to submit with realtime data. (Wait Until Flat.) You can observe the Strategies tab of the Control Center if the strategy is in a virtual position waiting to become flat. The strategy will be orange/yellow when waiting to for the historical position to be closed, and will be green when allowed to trade live.

    Strategy Position vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
    Start Behaviors - https://ninjatrader.com/support/helpGuides/nt7/syncing_account_positions.htm

    Debugging Tips

    In order to better understand how the code is executing, I recommend adding debugging prints to your strategy. By adding prints for the values used to evaluate your conditions outside of those conditions, you can observe if logic is becoming true and allowing your order submission methods to fire.

    If you are seeing your order submission logic being reached, but it is not executing, there may be an issue where the strategy is already in a virtual position that is not allowing you to re-enter. TraceOrders can be enabled in the strategy's Initialize method so the strategy prints its order feedback, and you may also observe the log tab of the Control Center for additional hints.

    Some items to check when you are taking debugging steps:
    1. Are your conditions allowing your order submission methods to be reached?
    2. Is the strategy currently in a position that is preventing it from submitting another entry order?
    3. Do you see any errors in the log tab of the Control Center or does Trace Orders give you any feedback?
    I've included some tips for debugging below. The Playback Connection can be used to replay data as if it were realtime.

    Debugging Tips - https://ninjatrader.com/support/helpGuides/nt7/debugging_your_ninjascript_cod.htm
    TraceOrders - https://ninjatrader.com/support/helpGuides/nt7/traceorders2.htm
    Market Replay - https://ninjatrader.com/support/help...ket_replay.htm

    Please let us know if there is anything else we can do to help.
    Last edited by NinjaTrader_Jim; 03-05-2020, 10:07 AM.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by WHICKED, Yesterday, 09:03 PM
    1 response
    14 views
    0 likes
    Last Post Emma1
    by Emma1
     
    Started by oleotrim, Yesterday, 11:29 PM
    1 response
    8 views
    0 likes
    Last Post Emma1
    by Emma1
     
    Started by Heavyweight_Prop, Yesterday, 09:06 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by saltminer, Yesterday, 05:49 PM
    0 responses
    9 views
    0 likes
    Last Post saltminer  
    Started by brunoviveiros, Yesterday, 05:32 PM
    0 responses
    5 views
    0 likes
    Last Post brunoviveiros  
    Working...
    X