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:
    http://www.ninjatrader.com/support/f...ead.php?t=6651
    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:
        http://www.ninjatrader.com/support/f...ead.php?t=3228
        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 nnwakaihe, Today, 08:19 AM
                  1 response
                  21 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by Rocket, Yesterday, 06:03 PM
                  1 response
                  42 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by newton1, Yesterday, 09:54 AM
                  2 responses
                  62 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by SuperDude123, Yesterday, 08:31 AM
                  3 responses
                  101 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by jeliner, Yesterday, 12:58 AM
                  1 response
                  32 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X