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

Newbie issue - strategy runs in Strategy Development but not live

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

    Newbie issue - strategy runs in Strategy Development but not live

    Hi guys, I feel like despite having saint-like patience, the good people at Ninjatrader support may get fed up with me if I ask them yet another question, so I thought I would start posting on here instead so other Ninjascript blackbelts can hopefully help a noob out...

    I have made a very simple strat which runs in Strategy Analyser. It enters when it's supposed to at least. However, when I run it on live charts in SIM101 mode, it doesn't enter when the entry conditions are met. That is to say it doesn't generate any entries at all.

    Can anyone please suggest any possible casuses for this?

    Also, links to any noob guides for Ninjascript editor or basic c# courses would be much appreciated!

    Cheers,

    Skotten84


    #2
    Welcome to the forums Skotten84,

    I have made a very simple strat which runs in Strategy Analyser. It enters when it's supposed to at least. However, when I run it on live charts in SIM101 mode, it doesn't enter when the entry conditions are met. That is to say it doesn't generate any entries at all.
    A common issue that we see is that the strategy is taking some behaviors differently between historical and realtime data and all of the nuances behind strategy behaviors are not understood. Order fills and strategy logic will be different between historical and realtime environments and the strategy may be in a historical position while using the Wait Until Flat start behavior which would prevent the strategy from submitting live orders until it returns to a flat position.

    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.

    Ultimately, debugging steps should be taken to observe the strategy logic as it is executing.

    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 (set in State.SetDefaults or in the Strategy Builder under Default Properties) so it 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/help...script_cod.htm
    TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm
    Debugging in the Strategy Builder - https://www.screencast.com/t/8uvjfM8h
    Playback Connection - https://ninjatrader.com/support/help...connection.htm

    Below are links to documentation resources that further explain Strategy vs. Account Position, Discrepancies between Historical and Realtime data, Start Behaviors, and the internal rules of the Managed Approach. (The Strategy Builder generates Managed Approach NinjaScript strategy code.)

    Discrepancies between historical and Realtime data - https://ninjatrader.com/support/help...ime_vs_bac.htm
    Strategy Position vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
    Start Behaviors - https://ninjatrader.com/support/help..._positions.htm
    Managed Approach (Internal Rules) - https://ninjatrader.com/support/help...antedPositions

    Please let us know if you have any additional questions or have any questions on the debug output you are receiving.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 12:36 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by yertle, Yesterday, 08:38 AM
    8 responses
    36 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by rdtdale, Today, 01:02 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    19 views
    0 likes
    Last Post RookieTrader  
    Working...
    X