Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OHLC plot from strategy

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

    OHLC plot from strategy

    Hi, I need to plot OHLC bars from a strategy and I'm using NinjaTrader 8.

    I read that it's possible to write custom code to plot the OHLC but can't find any examples.

    Any help would be appreciated.

    Thank you.
    Last edited by hungdale; 11-10-2017, 01:14 PM.

    #2
    Hello,

    Thanks for your post.

    Please provide me with a little more detail on what you would like to do. Is there a specific reason that you want to plot these bars from a strategy?

    You could use an indicator for this and wouldn't need a strategy unless you need to calculate something special on order, execution, etc.

    I look forward to your reply.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh, Thanks for your reply. There are several reasons why I would like this capability.

      A) I need intra-bar order handling but would prefer to deal with data on a tick per tick basis for simplicity.

      B) Would accommodate a custom bar type but bar parameters could be fed into an optimization engine as well.

      C) A visual confirmation that the bars are calculated correctly since they drive the underlying strategy.

      Would be preferable to have all on one chart, but could be a solution if I could feed an indicator tick data and then pull the indicator values into the strategy but it doesn't look like indicators can plot OHLC either.

      Comment


        #4
        Hello,

        You can run an optimization on your Data Series as well as your strategy. You can find the option to optimize your data series inside the Strategy Analyzer when you have "Optimization" set as your backtest type. It will be found under Settings>Optimize>Optimize Data Series. You will then have extra Data Series option that you can configure.

        You should also know that OHLC is a chart style and not a bar type. You would be able to set your charts style to OHLC, then apply your strategy, and you would get the strategy behavior you are looking for. This option can be found inside your Data Series' properties under 'Chart style'.

        If you truly want to plot OHLC from a strategy you can look into the following forum post. The concepts detailed there, as well as the sample files, will help you to accomplish what you are looking for.
        https://ninjatrader.com/support/foru...ead.php?t=6651

        Please let me know if you have any further questions.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          I think you must be talking about overriding OnRender?

          Comment


            #6
            Hello hungdale,

            Thank you for your response.

            If you wanted to draw bars in a specific manner then you would in fact need to override OnRender. However, based on your detail there is no need for such complexity to your project. I would recommend simply changing your chart style to OHLC. There is no need to force a strategy to perform this function as it is already in place and is only a visual item that has no effect on the calculations you strategy would perform on the price data.

            With that detail in mind are you attempting to use your strategy to calculate the Open, High, Low, or Close of the chart bars? Why not use a Bars Type for this purpose?

            To be clear a Bars Type is the bar itself and not it's visual display. Consider how a 1 Minute chart can be displayed as OHLC, Candle Stick, Line On Close, etc. These chart styles are merely visual and have no affect on the actual bar's Open, High, Low, or Close. A Bars Type will be what controls the Open, High, Low, and Close of the bars on the chart.

            Chart Style: https://ninjatrader.com/support/help...hart_style.htm
            Bars Type: https://ninjatrader.com/support/help.../bars_type.htm

            I look forward to your response.

            Comment


              #7
              Thank you.

              At this point, I have OnRender displaying what I need but I don't want the strategy to be more complicated than it needs to be.

              From what you are describing, sounds like I I need to...

              1) Create a 1 tick OHLC chart so I can have the highest resolution for order handling and tick data for my custom OHLC bars.

              2) Have my strategy evaluate each tick and generate the data for my OHLC bars.

              3) Plot the OHLC data from within the strategy, but how?

              I always use the OHLC style so the problem I have is how do I get my custom OHLC data to plot correctly. Do I add 4 new data series or do I AddPlot 4 times, one for open, one for high, etc, etc...

              Maybe I need to add another data series and treat this as a multi time frame strategy?

              Comment


                #8
                Hello hungdale,

                Thank you for your response.

                Please refer to the Heiken Ashi indicator for NinjaTrader 8. This is the how you would alter the chart bars in OnRender: https://ninjatrader.com/support/foru...d=7&linkid=730

                In that example four plots are used.

                However, you have yet to explain why a strategy is necessary here. Can you please detail why you are taking this approach so we can provide specific details on how to create what you wish?

                I look forward to your response.

                Comment


                  #9
                  Thanks Patrick, As I mentioned, I already have OnRender working to plot my custom bars from my strategy. But like you said, I should probably not use OnRender unless it's the only option. So, I would like to know how to plot my custom OHLC bars from my strategy by just using the plot functions already available to a strategy.

                  There are a few reasons why I would like this.

                  I had been with TradeStation since 2000 and dealing with intra bar orders is very difficult to me.

                  Also, I have a custom OHLC bar that is used to drive the strategy. So, if I put my strategy on a 1 tick chart, I fix three problems. The tick data is used to build the bars for the strategy, the strategy displays the bars, and I can make trade decisions on each tick.

                  Comment


                    #10
                    Hello hungdale,

                    Thank you for your response.

                    Using OnRender would be the correct approach in this case.

                    Please let me know if you have any questions.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by op1031, Yesterday, 05:16 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NT-Roland  
                    Started by sinpeople, Today, 07:20 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NT-Roland  
                    Started by Frank1000, Today, 03:05 AM
                    1 response
                    7 views
                    0 likes
                    Last Post NT-Roland  
                    Started by ntdev, Today, 01:14 AM
                    4 responses
                    16 views
                    0 likes
                    Last Post ntdev
                    by ntdev
                     
                    Started by ct, Today, 02:22 AM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Jason  
                    Working...
                    X