Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switching between Bid/Ask/Last chart through script

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

    Switching between Bid/Ask/Last chart through script

    Hello,

    I am switching back and forth between a Bid and Ask candlestick chart using two custom buttons on the main tool bar.

    I am currently making the switch through the ChartBars properties:

    Code:
    foreach (var obj in _parentchartWindow.ActiveChartControl.ChartObjects)
                {
                    var prices = obj as ChartBars;
    
                    if (prices != null)
                    {
                        prices.Properties.BarsPeriod.MarketDataType = MarketDataType.Bid;
                    }
                }
    The issue I ran into is that the chart will not re-paint with the new MarketDataType until I invoke ReloadAllHistoricalData() which is not preferred for obvious reasons. If all bid/ask prices are already cached, there's no point in reloading them.

    When the 'Price based on' property is changed manually by the user within the Data Series dialog and applied, it does not appear that all data is being reloaded.

    Is there a function in NinjaScript I've overlooked to invoke the chart to repaint with the new prices? I would prefer not to create new ChartTypes for this as the style is not really changing; only the price source.

    Thank you in advance.

    #2
    Hello CDXTrader,

    Thank you for your post.

    You can look into ForceRefresh for this purpose: http://ninjatrader.com/support/helpG...rcerefresh.htm

    Please let me know if you have any questions.

    Comment


      #3
      Hello,

      Thanks for the reply. I should have mentioned that ForceRefresh was actually the first approach I used with no success.

      ForceRefresh appears to work for all other visual-style changes (chart colors, wicks, drawing objects, execution plots, etc.) but not for changing the market data type. Other options?

      Thank you.

      Comment


        #4
        Hello CDXTrader,

        Thank you for your response.

        You could have both plot but have one transparent until you switch them. Since they are held in memory in any case you are only adding the additional cost of them being in memory as painted already.

        Please let me know if you have any questions.

        Comment


          #5
          Hi Patrick,

          It seems like a bit of a detour from the way it should work but your suggestion seems viable. I will give it a shot. Thank you

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          55 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          72 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          38 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          99 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          60 views
          0 likes
          Last Post PaulMohn  
          Working...
          X