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

Help with plotting values to DataBox for strategy use

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

    Help with plotting values to DataBox for strategy use

    I am looking for to plot all availble support reistance levels (upper and lower price), so it can be used in strategy. I want to start with plotting the type R for resistance and s for Support. it compains that it cant convert. Issue is probably with referencing list type correctly.

    Currently indicator is not plotting anything to the databox
    I was hoping some one can help



    AddPlot(Brushes.Blue, "MyPlot1"); // <-- this becomes Values[0]
    AddPlot(Brushes.Green, "MyPlot2"); // <-- this becomes Values[1]​

    MyPlot1[0] = FVGType.R;
    MyPlot2[0] = FVGType.S;​

    [Browsable(false)]
    [XmlIgnore]
    public Series<FVGType> MyPlot1
    { get { return Values[0]; } }

    [Browsable(false)]
    [XmlIgnore]
    public Series<FVGType> MyPlot2
    { get { return Values[1]; } }​

    Code:
     public class FVGIndTest : Indicator
        {
            // Support or Resistance FVG
            public enum FVGType
            {
                S, R
            }
    
            #region Class FVG
    //        public List<FVGTYPESR> ;
            public class FVG
    
            {
                public double upperPrice;
                public double lowerPrice;
                public double consequentEncroachmentPrice;
                public string tag;
                public FVGType type;
                public bool filled;
                public DateTime gapStartTime;
                public DateTime fillTime;
    
                public FVG(string tag, FVGType type, double lowerPrice, double uppperPrice, DateTime gapStartTime)
                {
                    this.tag = tag;
                    this.type = type;
                    this.lowerPrice = lowerPrice;
                    this.upperPrice = uppperPrice;
                    this.consequentEncroachmentPrice = (this.lowerPrice + this.upperPrice) / 2.0;
                    this.filled = false;
                    this.gapStartTime = gapStartTime;
                }
            }
            #endregion
    ​
    Click image for larger version

Name:	image.png
Views:	87
Size:	580.4 KB
ID:	1269169

    Click image for larger version

Name:	image.png
Views:	199
Size:	7.3 KB
ID:	1269168

    #2
    Hello tkaboris,

    Plots are type Series<double> you need to change the public properties you made to use Series<double> instead.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I changed that but still have error.
      FVGType.R is not a double it returns enum R or S
      Click image for larger version

Name:	image.png
Views:	78
Size:	346.5 KB
ID:	1269178

      Comment


        #4
        Hello tkaboris,

        If those are plots you need to use a bars ago with them to get a value. [0]
        JesseNinjaTrader Customer Service

        Comment


          #5
          it says it cant apply indexing
          Click image for larger version

Name:	image.png
Views:	78
Size:	372.3 KB
ID:	1269181

          Comment


            #6
            Hello tkaboris,

            Unfortunately I am not sure what you are trying to accomplish with the code you had provided in post 1. You would need to have some kind of price value if you want to set a plot. Looking at that code you provided the R and S are enums, you would have to use code that returns a price instead.

            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by llanqui, Today, 03:51 PM
            0 responses
            2 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by Quanto, 04-17-2024, 10:43 AM
            2 responses
            22 views
            0 likes
            Last Post Quanto
            by Quanto
             
            Started by Irukandji, Today, 03:06 PM
            0 responses
            6 views
            0 likes
            Last Post Irukandji  
            Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
            17 responses
            95 views
            0 likes
            Last Post cmtjoancolmenero  
            Started by nleitman, Today, 11:46 AM
            8 responses
            20 views
            0 likes
            Last Post nleitman  
            Working...
            X