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

FormatPriceMarker question

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

    FormatPriceMarker question

    I have an indicator that has multiple plots on a sub panel. The plots are from different instruments and I would like the price markers to reflect which line is which instrument. I am using this code for the signal plot

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

    But I don't know how to change the markers for multiple plots

    The attached screen shot shows the two plots from two different instruments, but has the ES on both.

    Thanks
    Attached Files

    #2
    Hello mlarocco,

    Thank you for your note.

    Would you please provide a copy or simplified version of the indicator so I may take a look on our end?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      See below...

      protected override void Initialize()
      {
      Add(new Plot(Color.Transparent, PlotStyle.Line, "MACDBB1"));
      Add(new Plot(Color.Transparent, PlotStyle.Line, "MACDBB1"));
      Add(new Plot(Color.DarkGray, PlotStyle.Line, "Inst_Line_1"));
      Add(new Plot(Color.DarkGray, PlotStyle.Line, "Inst_Line_2"));
      Plots[2].Pen.Width = 10;
      Plots[3].Pen.Width = 10;
      //Plots[0].Pen.DashStyle = DashStyle.Dash;


      Overlay = false;
      PriceTypeSupported = true;
      CalculateOnBarClose = false;

      Add(instrument1, PeriodType.Custom9, barValue1);
      Add(instrument2, PeriodType.Custom9, barValue2);
      }

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

      //public override string FormatPriceMarker(double price)
      //{
      //return price.ToString(instrument2);
      //}

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      if (CurrentBar < 1)
      return;


      Inst_Line_1.Set(1);
      Inst_Line_2.Set(1.5);
      Values[0].Set(HPT_MACDBB(BarsArray[1],20, 12, 1, 45, 5).MACDPlot[0]);
      Values[1].Set(HPT_MACDBB(BarsArray[2],20, 12, 1, 45, 5).MACDPlot[0]);
      //Value.Set(HPT_MACDBB(20, 12, 1, 45, 5).MACDPlot[0]);


      //Instrument 1
      if(Values[0][0] > 1)
      {
      if(slopeColor)
      PlotColors[2][0] = upColor;
      }
      if(Values[0][0] < -1)
      {
      if(slopeColor)
      PlotColors[2][0] = dnColor;
      }

      //Instrument 2
      if(Values[1][0] > 1)
      {
      if(slopeColor)
      PlotColors[3][0] = upColor;
      }
      if(Values[1][0] < -1)
      {
      if(slopeColor)
      PlotColors[3][0] = dnColor;
      }

      Comment


        #4
        Hello mlarocco,

        I have attached a sample indicator which will display the contract associated with the plot on the axis. I use an if statement to check if the price is above 3,000, and the two additional series are the ES and NQ.

        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          This does work but the only problem

          I see is, if the instruments are changed then the 3000 or whatever number is used may not be valid then.

          Comment


            #6
            Hello mlarocco,

            That is correct. You could add logic to handle this. In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients.

            You can also contact a professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by trilliantrader, Today, 08:16 AM
            0 responses
            3 views
            0 likes
            Last Post trilliantrader  
            Started by AttiM, 02-14-2024, 05:20 PM
            9 responses
            174 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by funk10101, Today, 08:14 AM
            0 responses
            2 views
            0 likes
            Last Post funk10101  
            Started by adeelshahzad, Today, 03:54 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by RookieTrader, Today, 07:41 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X