Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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

  • NinjaTrader_Jim
    replied
    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.

    Leave a comment:


  • 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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by funk10101, Today, 12:02 AM
1 response
10 views
0 likes
Last Post NinjaTrader_LuisH  
Started by GLFX005, Today, 03:23 AM
1 response
6 views
0 likes
Last Post NinjaTrader_Erick  
Started by nandhumca, Yesterday, 03:41 PM
1 response
12 views
0 likes
Last Post NinjaTrader_Gaby  
Started by The_Sec, Yesterday, 03:37 PM
1 response
11 views
0 likes
Last Post NinjaTrader_Gaby  
Started by vecnopus, Today, 06:15 AM
0 responses
1 view
0 likes
Last Post vecnopus  
Working...
X