Announcement

Collapse
No announcement yet.

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.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      590 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      342 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      555 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X