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 Christopher_R, Today, 12:29 AM
                  0 responses
                  9 views
                  0 likes
                  Last Post Christopher_R  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  166 responses
                  2,235 views
                  0 likes
                  Last Post sidlercom80  
                  Started by thread, Yesterday, 11:58 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post thread
                  by thread
                   
                  Started by jclose, Yesterday, 09:37 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jclose
                  by jclose
                   
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  10 responses
                  1,415 views
                  0 likes
                  Last Post Traderontheroad  
                  Working...
                  X