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

IsSuspendedWhileInactive works for onMarketData?

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

    IsSuspendedWhileInactive works for onMarketData?

    Hi,

    for my indicator I need to use the onMarketData event. Usually I load the indicator (it's a volume profile) on the chart and then I leave it in the background. It happens that if I do not look at the chart for long time (say 20-30 minutes) then I see some "holes" in the volume profile. Note that the internet connection is not a problem because my pc is always connected and in addition while the price chart with the indicator is in the background I do use other softwares so the pc does not go in sleep mode.
    As a possible solution I have tried to set IsSuspendedWhileInactive = false in (State == State.SetDefaults) but without success. I was wondering if it is because such setting does not apply to onMarketData? What kind of solution do you suggest?

    Thank you!
    Cheers

    #2
    Let me add some more information: when I write "leave it in the background" I mean click on the chart minimize button.

    In addition, I have tried to add a Print(DateTime.Now) within the onMarketData: if I keep the chart opened I can see the current time being printed continuously on the output; however, as soon as I click minimize I do not see any line printed anymore in the ninjascript output. Please note that I still have the IsSuspendedWhileInactive = false in (State == State.SetDefaults).

    Do you have any idea?

    Thank you

    Comment


      #3
      Hello VFI26,

      Thank you for your post.

      As a test, I added the following logic to an indicator and checked the NinjaScript Output window with IsSuspendedWhileInactive set to true vs. false:
      Code:
              protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
              {
                  // Print some data to the Output window
                  if (marketDataUpdate.MarketDataType == MarketDataType.Last)
                      Print(string.Format("Last = {0} {1} ", marketDataUpdate.Price, marketDataUpdate.Volume));
                  else if (marketDataUpdate.MarketDataType == MarketDataType.Ask)
                      Print(string.Format("Ask = {0} {1} ", marketDataUpdate.Price, marketDataUpdate.Volume));
                  else if (marketDataUpdate.MarketDataType == MarketDataType.Bid)
                      Print(string.Format("Bid = {0} {1}", marketDataUpdate.Price, marketDataUpdate.Volume));
              }
      
              protected override void OnBarUpdate()
              {
                  if (State == State.Historical)
                      return;
                  if (IsFirstTickOfBar)
                      Print(Time[0] + " OBU");
              }​
      What I observed is when it is true and I minimized the chart the indicator was applied to, I no longer saw the OnMarketData() prints. When it was set to false, even when I minimized the chart I saw the prints. This is because, as note number 7 on the help guide page below says, OnMarketData() is expected to be called after OnBarUpdate():


      In order to ensure your indicator is still getting the desired market data updates, you will need to set IsSupsendedWhileInactive to false. You mentioned you still see gaps in data; please check the Log tab of the Control Center for any error messages or connection details that could be related. You could also try adding prints to your indicator script for further debugging:


      Please let us know if we may be of further assistance.
      Emily C.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      11 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      16 views
      0 likes
      Last Post AaronKoRn  
      Working...
      X