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 selu72, Today, 02:01 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by WHICKED, Today, 02:02 PM
                  2 responses
                  12 views
                  0 likes
                  Last Post WHICKED
                  by WHICKED
                   
                  Started by f.saeidi, Today, 12:14 PM
                  8 responses
                  21 views
                  0 likes
                  Last Post f.saeidi  
                  Started by Mikey_, 03-23-2024, 05:59 PM
                  3 responses
                  51 views
                  0 likes
                  Last Post Sam2515
                  by Sam2515
                   
                  Started by Russ Moreland, Today, 12:54 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Working...
                  X