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 disables itself immediately

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

    Strategy disables itself immediately

    I converted an indicator, that I designed, to a strategy, and I'm still working on finishing it out. However, one problem that I've run into and can't figure out why it keeps disabling itself right away. I have a TrendChannel and a few lines drawing on the screen, and that is happening. However, after everything draws, you can see in the output log window that it's disabled the strategy. The logs are included below:

    Enabling NinjaScript strategy 'TestStrat/162181949' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
    Strategy 'TestStrat': Error on calling 'OnBarUpdate' method on bar 6028: Input string was not in a correct format.
    Disabling NinjaScript strategy 'TestStrat/162181949'
    Enabling NinjaScript strategy 'TestStrat/162181949' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
    Strategy 'TestStrat': Error on calling 'OnBarUpdate' method on bar 6030: Input string was not in a correct format.
    Disabling NinjaScript strategy 'TestStrat/162181949'
    Enabling NinjaScript strategy 'TestStrat/162181949' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
    Strategy 'TestStrat': Error on calling 'OnBarUpdate' method on bar 6033: Input string was not in a correct format.
    Disabling NinjaScript strategy 'TestStrat/162181949'
    Enabling NinjaScript strategy 'TestStrat/162181949' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
    Strategy 'TestStrat': Error on calling 'OnBarUpdate' method on bar 6123: Input string was not in a correct format.
    Disabling NinjaScript strategy 'TestStrat/162181949'
    Enabling NinjaScript strategy 'TestStrat/162181949' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
    Strategy 'TestStrat': Error on calling 'OnBarUpdate' method on bar 6127: Input string was not in a correct format.
    Disabling NinjaScript strategy 'TestStrat/162181949'
    I can see that there's a string that it doesn't like, but how can I identify that string?

    #2
    Hello learningnt,

    Thanks for your post.

    At this point, you will need to begin debugging your script to see where/when the error is. Debugging typically involves adding Print() statements to your code, reference: https://ninjatrader.com/support/help...-us/?print.htm

    Print statements output will appear in the Ninjascript output window which you can open from the control center via New>Ninjascript Output. Reference: https://ninjatrader.com/support/help...us/?output.htm

    Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm

    If you are unsure where in your script error may be occurring, a common approach is to place a print statement every X lines of code and to print out a sequential value so that when you look at the output window you would see the sequential values and the last value printed would show the last successful line, indicating the error occurred after that value/line. Once you have that then you can add additional print statements to try to find the specific line of code that is producing the error by placing additional print statements. Once you have identified the line of code causing the error you can then begin printing out the variables involved with that error line and find the source of the error.

    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rocketman7, Today, 01:00 AM
    0 responses
    1 view
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    27 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 04-23-2024, 09:53 PM
    2 responses
    74 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    193 views
    0 likes
    Last Post Hasadafa  
    Working...
    X