• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 Why doesnt this indicator work?

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

    NT8 Why doesnt this indicator work?

    Hi Guys!

    I have compiled this indicator from an NT7 version.
    It should plot an opening range every day, but it only plot on one day a couple of days back never on the sameday.


    Thanks,!!!
    ------------------------------------------------------------
    //
    // Copyright (C) 2016, NinjaTrader LLC <www.ninjatrader.com>.
    // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
    //
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    using SharpDX;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class AAORZone : Indicator
    {
    private Brush rangeAreaColor = Brushes.Red;
    private double wk_zonesize = .0001;
    private double HighestHigh = 0;
    private double LowestLow = 0;


    // simple state machine: 0-Waiting, 1-Collecting, 2-Finished
    private int StateOfTime = 0;


    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = " ";
    Name = "AAORZone";
    Calculate = Calculate.OnEachTick;
    DrawOnPricePanel = true;
    IsChartOnly = true;
    IsOverlay = true;
    DisplayInDataBox = false;
    PaintPriceMarkers = false;
    RangePlusTicks = 20;
    RangeAreaOpacity = 30;
    BeginTime = 90000;
    EndTime = 90500;

    AddPlot(new Stroke(Brushes.Transparent,1), PlotStyle.Hash, "ORHigh");
    AddPlot(new Stroke(Brushes.Transparent,1), PlotStyle.Hash, "ORLow");
    AddPlot(new Stroke(Brushes.Maroon,1), PlotStyle.Hash, "ORHighPlus");
    AddPlot(new Stroke(Brushes.Maroon,1), PlotStyle.Hash, "ORLowPlus");

    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Second, 1);
    }
    }
    protected override void OnBarUpdate()
    {
    wk_zonesize = RangePlusTicks * TickSize;
    if (BarsInProgress == 0)
    {
    if (HighestHigh > 0 && LowestLow > 0 && ToTime(Time[0]) > BeginTime)
    {
    ORHigh[0] = HighestHigh;
    ORLow[0] = LowestLow;
    ORHighPlus[0] = (HighestHigh + wk_zonesize);
    ORLowPlus[0] = (LowestLow - wk_zonesize);
    Draw.Region(this,"ColorRange", CurrentBar, 0, ORHigh, ORLow, Brushes.Transparent, RangeAreaColor, RangeAreaOpacity);
    }
    }

    if (BarsInProgress == 1)
    {
    if (Bars.IsFirstBarOfSession)
    {
    HighestHigh = 0;
    LowestLow = 0;
    State = 0;
    }

    // waiting for start of opening range
    if (StateOfTime == 0)
    {
    if (ToTime(Time[0]) >= BeginTime && ToTime(Time[0]) < EndTime)
    {
    HighestHigh = High[0];
    LowestLow = Low[0];
    StateOfTime = 1;
    }
    }

    // collecting opening range?
    else if (StateOfTime == 1)
    {
    if (ToTime(Time[0]) < EndTime)
    {
    if (High[0] > HighestHigh)
    HighestHigh = High[0];
    if (Low[0] < LowestLow)
    LowestLow = Low[0];
    }
    else
    // collection finished
    StateOfTime = 2;
    }
    }
    }


    #region Properties

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

    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> ORLow
    {
    get { return Values[1]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> ORHighPlus
    {
    get { return Values[2]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> ORLowPlus
    {
    get { return Values[3]; }
    }

    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Begin Time e.g.: 90000", GroupName = "OR", Order = 0)]
    public int BeginTime
    { get; set; }

    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "End Time e.g.: 90500", GroupName = "OR", Order = 1)]
    public int EndTime
    { get; set; }

    [XmlIgnore()]
    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Range Area Color", GroupName = "OR", Order = 2)]
    public Brush RangeAreaColor
    {
    get { return rangeAreaColor; }
    set { rangeAreaColor = value; }
    }

    [Range(0, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Range Area Opacity", GroupName = "OR", Order = 3)]
    public int RangeAreaOpacity
    { get; set; }

    [Range(0, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Range Plus Ticks", GroupName = "OR", Order = 4)]
    public int RangePlusTicks
    { get; set; }

    [Browsable(false)]
    public string RangeAreaColorSerialize
    {
    get { return Serialize.BrushToString(rangeAreaColor); }
    set { rangeAreaColor = Serialize.StringToBrush(value); }
    }
    #endregion
    }
    }

    #2
    Hello Gregorio,

    So that I may have a more complete picture of what is happening on your end, would it be possible to use the freely and publicly available screen capture software Jing, https://www.techsmith.com/jing.html , or a similar program which can record video of what is happening on your screen, so that you can show me what is occurring on your end? These quick instructions can get you started with Jing.

    1. When you start Jing, a yellow half circle will appear near the top of your screen. Please hover over it with your mouse
    2. A small + sign will extend out of this half circle. Please click on it
    3. When your cursor becomes two intersecting lines, please click and drag your mouse over an area of your screen you would like to record
    4. Please press the film strip button that appears to begin recording
    5. When you are finished recording, please press the square stop button that appears
    6. Please press the share button that appears. It consists of three vertical upward pointing arrows.

    You will then have the option to view your video on screencast.com . This is the link which can help me diagnose what is happening on your end. It is possible you will need to set up a free account in order to share videos.




    Thank you very much in advance for providing us with this information. If this procedure is not an option for you, or if there are any other questions we can answer, please let us know.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      I may have been a little confusing

      What i meant: In ES, CL or GC it prints only on one day and not all. Which wouldnt be a problem if that day would be the present day. But it isnt. With the video I couldnt show more. The indicator should plot an opening range and two lines above and below the range in red color. Thats all.
      NT8 is not showing any errors in script. While in use, no error messages either.
      Why isnt it plotting on all days? Is this a session related or time related problem?

      Comment


        #4
        Thank you for this additional information. With a video I would be able to see some information as far as how exactly your charts are being loaded, including any data series settings, indicator settings, and properties. It would clear up many ambiguities. For example, where you mentioned range bars, a video would let me know exactly how large the range bars are. Since I am asking for a lot of information all at once, so that I can try to repeat what you are seeing on my end, and I believe it would be tedious to type all the information I am requesting out, if a video could be provided it would be ideal.

        I will attempt to proceed with only the information I have been given and will get back to you shortly.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          I am using 3 min bars and want to plot an OR between two times e.g: 9:00 to 9:05
          I try to do a recording soon, but until that lets try this way. :-)
          Thanks!

          Comment


            #6
            Hello Gregorio,

            I have all the parts of your code against the latest copy of NinjaTrader, and NinjaTrader behaved as expected. I believe, therefore, that you will need to review your code to get your indicator to plot the way you would like. We are happy to help with this process with any specific questions you have regarding how NinjaTrader and NinjaScript operate. If you would like some help finding a certified NinjaScript consultant, who can do more in depth debugging and development of your own code, please let us know and we will be happy to provide more information as well.
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Yes, can you link me somebody who understands script and can point me to the right direction?

              Comment


                #8
                Hello Gregorio,


                Thank you for contacting us and for your interest in NinjaTrader!



                I have provided a link below that will show you the NinjaTrader Ecosystem partners that provide NinjaScript Consulting services, you will need to contact each prospective consultant and inquire further regarding the quotes for prices for your custom NinjaScript ideas and work with the consultant directly:




                Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
                Ryan L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by SAILIKITY, 05-22-2019, 05:41 PM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by rmillar, 01-09-2019, 06:02 PM
                6 responses
                60 views
                1 like
                Last Post eDanny
                by eDanny
                 
                Started by mlarocco, Today, 11:39 AM
                4 responses
                19 views
                0 likes
                Last Post mlarocco  
                Started by roblogic, Today, 11:19 AM
                2 responses
                15 views
                0 likes
                Last Post roblogic  
                Started by saeed, Today, 10:17 AM
                8 responses
                48 views
                0 likes
                Last Post NinjaTrader_Kate  
                Working...
                X