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 does not work even if it is activated

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

    strategy does not work even if it is activated

    Hello,
    I have a strategy which consists of reading a file with Streamreader which I use in the Onmarketdata function. this strategy works well but after 2 hours it does not read the file and yet it is still activated and gives no error message in the log
    thank you for your help

    #2
    Hello Red1111,

    Thank you for your post and welcome to the NinjaTrader forum community.

    Is there a reason you are using StreamReader in OnMarketData() rather than another method like OnBarUpdate()? Does it consistently stop reading after 2 hours, or is there a correlation with the time of day or any other similarities?

    I suggest adding Print() statements throughout your strategy to get a better understanding of which parts of your logic are being met and which ones are not. If you add prints both before and after StreamReader is used in your strategy, then you can check the NinjaScript Output window to see if the prints continue to print or not. This will offer additional insight into what might be happening. For more info about using prints to debug your scripts:Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      thank you for your answer.
      the reason why I used onmarketdata is that it is the only function which allows me to create orders, with OnBarUpdate the orders are not created for me. the strategy stops working after a few hours, it's not always 2 hours. What do you think this could be due to?

      Comment


        #4
        Originally posted by Red1111 View Post
        Hello,
        thank you for your answer.
        the reason why I used onmarketdata is that it is the only function which allows me to create orders, with OnBarUpdate the orders are not created for me. the strategy stops working after a few hours, it's not always 2 hours. What do you think this could be due to?
        With only the information you have presented, I do not know what it could be due to. You should be able to submit orders from OnBarUpdate() so it sounds like there may be a greater issue at hand. You can ultimately verify if OnMarketData() is still being called by adding Print() statements as suggested in my previous post. Other items to consider are the instrument being used, what the trading hours are, if there are market data updates that should call OnMarketData() when you are seeing that the strategy stops, etc. Please double-check the Log tab of the Control Center for any error messages and ensure that the strategy is still enabled and did not get disabled for any reason.

        Another helpful debugging tool, especially when orders are not being submitted as expected like when you tried to send orders from OnBarUpdate(), is to enable TraceOrders in State.SetDefaults. TraceOrders sends information to the NinjaScript Output window when an order is submitted, ignored, changed, canceled, rejected, etc. For more information regarding TraceOrders:Please add prints to your strategy and let us know if you have questions about the output when your strategy stops.
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Austiner87, Today, 05:02 PM
        0 responses
        5 views
        0 likes
        Last Post Austiner87  
        Started by tonynt, 05-21-2019, 06:27 AM
        10 responses
        530 views
        1 like
        Last Post fiendtrades  
        Started by awwenzovs, Today, 08:03 AM
        2 responses
        15 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Started by Ashkam, 04-29-2024, 09:28 AM
        4 responses
        44 views
        0 likes
        Last Post Ashkam
        by Ashkam
         
        Started by nightstalker, Yesterday, 02:05 PM
        1 response
        31 views
        1 like
        Last Post NinjaTrader_Eduardo  
        Working...
        X