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

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 BarzTrading, Today, 07:25 AM
          2 responses
          24 views
          1 like
          Last Post BarzTrading  
          Started by devatechnologies, 04-14-2024, 02:58 PM
          3 responses
          20 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by tkaboris, Today, 08:01 AM
          0 responses
          4 views
          0 likes
          Last Post tkaboris  
          Started by EB Worx, 04-04-2023, 02:34 AM
          7 responses
          163 views
          0 likes
          Last Post VFI26
          by VFI26
           
          Started by Mizzouman1, Today, 07:35 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X