Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot in Strategies

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

    Plot in Strategies

    Is it possible to use plots in strategies instead of Drawing Objects, the same way you would use them in an Indicator? I have dots in a strategy that draw at a specific price under certain conditions. They create a line of dots for a period of time. I would prefer a simple dash (hash), but they are not available in drawing objects.
    Thanks

    #2
    Hi Ken,
    Yes, you could follow this sample for plotting within a NinjaScript strategy:
    When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks. How would pen width and dashstyle be added?

      Comment


        #4
        See here for common plot formatting like width and dashstyle:
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thank you...

          Comment


            #6
            I've successfully added strategy plots but they seem to use a lot of code. For 3 dotted lines it uses this code:

            protectedoverridevoid Initialize()
            {
            Add(StrategyPlot(0)); // Buy Entry Price
            StrategyPlot(0).Plots[0].Pen.Color = Color.Lime;
            StrategyPlot(0).Plots[0].Pen.Width = 3;
            StrategyPlot(0).Plots[0].Pen.DashStyle = DashStyle.Dash;
            StrategyPlot(0).PanelUI = 1;


            Add(StrategyPlot(1)); // Buy Target Price
            StrategyPlot(1).Plots[0].Pen.Color = Color.White;
            StrategyPlot(1).Plots[0].Pen.Width = 3;
            StrategyPlot(1).Plots[0].Pen.DashStyle = DashStyle.Dash;
            StrategyPlot(1).PanelUI = 1;


            Add(StrategyPlot(2)); // Buy Stop Price
            StrategyPlot(2).Plots[0].Pen.Color = Color.Gold;
            StrategyPlot(2).Plots[0].Pen.Width = 3;
            StrategyPlot(2).Plots[0].Pen.DashStyle = DashStyle.Dash;
            StrategyPlot(2).PanelUI = 1;

            }
            protectedoverridevoid OnBarUpdate()
            {
            if (condition)
            StrategyPlot(0).Value.Set(EntryPrice); // Buy Entry Price

            if (condition)
            StrategyPlot(1).Value.Set(TargetPrice); // Buy Target Price

            if (condition)
            StrategyPlot(2).Value.Set(StopPrice); // Buy Stop Price
            }

            Is there a more condensed or effecient way of accomplishing this and can "StrategyPlot(0)" be named something else like "EntryPricePlot"? This seems to use a lot of lines of code..

            Thanks

            Comment


              #7
              StrategyPlot is a dummy indicator, basically a placeholder for what you do with the plots in the strategy. You can name your own dummy indicator whatever you like.

              A strategies main purpose is for automated order placement, not charting. This structure is required in order to have the strategy do things that are generally more suited for an indicator.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                I changed the Name from "StrategyPlot" to "BuyTarget" and got an error that "BuyTarget" does not exist". How do I make it exist?

                Comment


                  #9
                  You only changed in the strategy? Create a new indicator through the indicator wizard and name it BuyTarget.
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by usazencort, Today, 01:16 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post usazencort  
                  Started by kaywai, 09-01-2023, 08:44 PM
                  5 responses
                  603 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Started by xiinteractive, 04-09-2024, 08:08 AM
                  6 responses
                  22 views
                  0 likes
                  Last Post xiinteractive  
                  Started by Pattontje, Yesterday, 02:10 PM
                  2 responses
                  21 views
                  0 likes
                  Last Post Pattontje  
                  Started by flybuzz, 04-21-2024, 04:07 PM
                  17 responses
                  230 views
                  0 likes
                  Last Post TradingLoss  
                  Working...
                  X