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

StrategyPlot() PlotStyle and Tick by TIck operation

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

    StrategyPlot() PlotStyle and Tick by TIck operation

    Is there a way to modify the StrategyPlot() method to change the PlotStyle?

    Also, I've applied some StrategyPlot() methods to a Strategy and it seems they do not start plotting until the completion of the bar even though the Strategy is set of CalculateOnBarClose = false. Is this the expected behavior?

    taddypole...

    #2
    Hello,

    Thanks for the forum post.

    Unfortunately I do not know of a way to change PlotStyle with a StrategyPlot. It can be done with a regular plot but I do not see an option to allow this with StrategyPlot.

    Also Strategy Plot should update when you set it. Do you have Calculate On Bar Close specified in the indicator in Initialize()?

    I look forward to assisting you further.

    Comment


      #3
      Hi Brett,

      Actually found the answer in another thread.
      use:

      StrategyPlot(index).Plots[0].PlotStyle = PlotStyle.Square;
      StrategyPlot(index).Plots[0].Pen.Color = Color.Green;

      And I found that the StrategyPlot was updating tick by tick.
      At first I thought is wasn't but later found out it was.

      Thanks for your assistance...

      taddypole...

      Comment


        #4
        I have the StrategyPlot() working but have one other problem.

        How do I adjust the number of displayed decimal points?
        For the EC I should be displaying 4 decimal places but with the plots displayed by the StrategyPlots I only get 2 decimal places.

        regards,
        taddypole...

        Comment


          #5
          Taddypole, do you have those running in the price panel or separate panel?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Bertrand,

            They are running in the price panel.
            Other indicators I have are displaying 4 decimals but the StrategyPlots() are displaying 2 decimals.

            Comment


              #7
              Thanks Taddypole, in this case you could custom format the price markers used in the StrategyPlot indicator:

              public override string FormatPriceMarker(double price)
              {
              return price.ToString("N4");
              }

              BertrandNinjaTrader Customer Service

              Comment


                #8
                Thanks Bertrand,

                But when I insert that code, I get compile errors.

                1. Where do I insert it? I've tried "OnBarUpdate" and "Initiallize" but get compile errors.
                2. Do I insert the code directly or is "price" a general term where I should be using "Close[0]"?

                Comment


                  #9
                  It would be outside OnBarUpdate(), as it's an own method to override the default markers, please see the cs attached adding this snippet in.
                  Attached Files
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    I notice your code is in an "indicator", mine is in a "Strategy".

                    Should the "FormatPriceMarker" also work in a Strategy?

                    I'm still getting compile errors.

                    Comment


                      #11
                      Specifically the error I'm getting is:


                      'NinjaTrader.Strategy.ManagedStrategySeven.FormatP riceMarker(double)': no suitable method found to override

                      Comment


                        #12
                        Hello,

                        Ah, yes running into that issue again where it may not be available in the strategy. I will check with Bertrand when he gets into the office to see if you can do this in a strategy with some workaround. I'm unaware of a way to do this with the strategy plot. The strategy plot is meant really to be a basic display to the chart only.

                        It may be beneficial to you to move all this into a separate indicator that you simply add on the chart with Add(IndicatorName()); in the strategy so that you do not run into these issues if you have more coding to do.

                        I look forward to assisting you further.

                        Comment


                          #13
                          I would but these StrategyPlots are various stops calculated based on a position entry.
                          Is there a way for code in an indicator to know when a position is entered and if it is long or short?

                          If not then I need the plots to come from the strategy.

                          regards,
                          taddypole...

                          Comment


                            #14
                            taddypole, this is unfortunately not possible - why not plot the stops you want to see visually with drawing objects?
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by ETFVoyageur, Today, 10:34 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post ETFVoyageur  
                            Started by sdauteuil, 09-23-2021, 10:16 AM
                            10 responses
                            1,263 views
                            0 likes
                            Last Post NinjaTrader_RyanS  
                            Started by Grantx, 05-31-2020, 06:49 AM
                            7 responses
                            1,384 views
                            0 likes
                            Last Post marcus2300  
                            Started by ETFVoyageur, 05-18-2024, 12:45 AM
                            3 responses
                            20 views
                            0 likes
                            Last Post ETFVoyageur  
                            Started by sylviannyc, Today, 09:07 AM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_ChristopherJ  
                            Working...
                            X