• 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

Re UniRenko Open Offset options

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

    Re UniRenko Open Offset options

    I am not a programmer but I am trying to and it might take me forever to do this (not sure) little simple thing.

    Would it be be possible to have an option to set the Open Offset of UniRenko in the Data Series to zero (0) instead of just having a default of one (1)?

    Appreciate very much.

    Regards,

    augus

    #2
    Hello augus,

    Thank you for your post and welcome to the NinjaTrader Support Forum!


    You can ask the developer of UniRenko for the alteration if you would like. Otherwise you would need to look into the code yourself to make this change.

    if you can provide the file here I can take a look as it should be as simple as setting the value as Math.Max(0, value).
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      I thought this is a Ninja Data Series as I saw it in the Ninja Data Series and invoked it? I really do not know how to or where to find the program. I think I have to start learning how to program or how to tweak a program as a newbie, from scratch. I just hope somebody could help me in the programming start up!

      Regards,

      augus

      Comment


        #4
        Hello augus,

        Thank you for your response.

        You can search the file sharing section of the Forum for the UniRenko and find it's developer from that search: http://ninjatrader.com/support/forum...splay.php?f=37

        If you downloaded elsewhere you will need to identify where.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Unirenko code

          i have the unirenko bar type. where do i find/extract the code? I think i also want to the same thing as augus. I want the unirenko bar to complete and a new bar to print when the price range meets (is equal to) the trend ticks number i set (4 ticks). Instead, what it's doing now is it only completes a bar and prints a new bar when price exceeds the trend ticks number i set.

          Comment


            #6
            Hello mrsonnim,

            Thank you for your post and welcome to the NinjaTrader Support Forum!

            I am not certain if the UniRenko is protected or not. If it is not protected then the code is located under Documents\NinjaTrader 7\bin\Custom\Type.

            Please let me know if you have any questions.
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              UniRenkoBarsType.cs

              Here is the unirenko file attached. just incase, i've also pasted the code below. thank you...

              //###
              //### Universal Renko Bar Type.
              //###
              //### Created: Gaston, June 2012
              //###
              using System;
              using System.ComponentModel;
              using System.Text.RegularExpressions;

              namespace NinjaTrader.Data
              {
              public class UniRenkoBarsType : BarsType
              {
              public UniRenkoBarsType() : base(PeriodType.Custom5) { }

              static bool registered = Register(new UniRenkoBarsType());
              double barOpen;
              double barMax;
              double barMin;
              double fakeOpen=0;

              int barDirection=0;
              double openOffset=0;
              double trendOffset=0;
              double reversalOffset=0;

              bool maxExceeded=false;
              bool minExceeded=false;

              double tickSize=0.01;

              public override void Add(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isRealtime)
              {
              //### First Bar
              if ((bars.Count == 0) || bars.IsNewSession(time, isRealtime))
              {
              tickSize = bars.Instrument.MasterInstrument.TickSize;

              trendOffset = bars.Period.Value * bars.Instrument.MasterInstrument.TickSize;
              reversalOffset = bars.Period.Value2 * bars.Instrument.MasterInstrument.TickSize;
              bars.Period.BasePeriodValue = bars.Period.Value; //### Remove to customize OpenOffset
              openOffset = Math.Ceiling((double)bars.Period.BasePeriodValue * 1) * bars.Instrument.MasterInstrument.TickSize;

              barOpen = close;
              barMax = barOpen + (trendOffset * barDirection);
              barMin = barOpen - (trendOffset * barDirection);

              AddBar(bars, barOpen, barOpen, barOpen, barOpen, time, volume, isRealtime);
              }
              //### Subsequent Bars
              else
              {
              Data.Bar bar = (Bar)bars.Get(bars.Count - 1);
              maxExceeded = bars.Instrument.MasterInstrument.Compare(close, barMax) > 0 ? true : false;
              minExceeded = bars.Instrument.MasterInstrument.Compare(close, barMin) < 0 ? true : false;

              //### Defined Range Exceeded?
              if ( maxExceeded || minExceeded )
              {
              double thisClose = maxExceeded ? Math.Min(close, barMax) : minExceeded ? Math.Max(close, barMin) : close;
              barDirection = maxExceeded ? 1 : minExceeded ? -1 : 0;
              fakeOpen = thisClose ; //### Fake Open is halfway down the bar

              //### Close Current Bar
              UpdateBar(bars, bar.Open, (maxExceeded ? thisClose : bar.High), (minExceeded ? thisClose : bar.Low), thisClose, time, volume, isRealtime);

              //### Add New Bar
              barOpen = close;
              barMax = thisClose + ((barDirection>0 ? trendOffset : reversalOffset) );
              barMin = thisClose - ((barDirection>0 ? reversalOffset : trendOffset) );

              AddBar(bars, fakeOpen, (maxExceeded ? thisClose : fakeOpen), (minExceeded ? thisClose : fakeOpen), thisClose, time, volume, isRealtime);
              }
              //### Current Bar Still Developing
              else
              {
              UpdateBar(bars, bar.Open, (close > bar.High ? close : bar.High), (close < bar.Low ? close : bar.Low), close, time, volume, isRealtime);
              }
              }

              bars.LastPrice = close;
              }

              public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes)
              {
              PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes);

              properties.Remove(properties.Find("BasePeriodType" , true));
              properties.Remove(properties.Find("PointAndFigureP riceType", true));
              properties.Remove(properties.Find("ReversalType", true));
              properties.Remove(properties.Find("BasePeriodValue ", true)); //### Remove to customize OpenOffset

              Gui.Design.DisplayNameAttribute.SetDisplayName(pro perties, "Value2", "\r\rTick Reversal");
              Gui.Design.DisplayNameAttribute.SetDisplayName(pro perties, "Value", "\r\rTick \rTrend");
              Gui.Design.DisplayNameAttribute.SetDisplayName(pro perties, "BasePeriodValue", "\r\rOpen Offset");

              return properties;
              }

              public override void ApplyDefaults(Gui.Chart.BarsData barsData)
              {
              barsData.Period.Value = 5; //### Trend Value
              barsData.Period.Value2 = 10; //### Reversal Value
              barsData.Period.BasePeriodValue = 1; //### Open Offset Value
              barsData.DaysBack = 10;
              }

              public override string ToString(Period period)
              {
              //return period.Value + " UniRenko T" +period.Value +"R" +period.Value2; //### Remove for OpenOffset
              return period.Value + " UniRenko T" +period.Value +"R" +period.Value2 +"O" +period.BasePeriodValue;
              }

              public override PeriodType BuiltFrom
              {
              get { return PeriodType.Tick; }
              }

              public override string ChartDataBoxDate(DateTime time)
              {
              return time.ToString(Cbi.Globals.CurrentCulture.DateTimeF ormat.ShortDatePattern);
              }

              public override string ChartLabel(Gui.Chart.ChartControl chartControl, DateTime time)
              {
              return time.ToString(chartControl.LabelFormatTick, Cbi.Globals.CurrentCulture);
              }

              public override object Clone()
              {
              return new UniRenkoBarsType();
              }

              public override int GetInitialLookBackDays(Period period, int barsBack)
              {
              return new RangeBarsType().GetInitialLookBackDays(period, barsBack);
              }

              public override int DefaultValue
              {
              get { return 4; }
              }

              public override string DisplayName
              {
              get { return "UniRenko"; }
              }

              public override double GetPercentComplete(Bars bars, DateTime now)
              {
              return 0;
              }

              public override bool IsIntraday
              {
              get { return true; }
              }
              }
              }

              Comment


                #8
                Hello mrsonnim,

                Thank you for your response.

                Are you looking for assistance in altering the code or someone to alter it for you?

                I look forward to your response.
                Patrick H.NinjaTrader Customer Service

                Comment


                  #9
                  Either way is fine by me if it's simple enough. Just some direction will do.

                  Comment


                    #10
                    Hello mrsonnim,

                    Thank you for your response.

                    Please keep in mind that BarType development in NinjaTrader 7 is unsupported.

                    Look in the code and you will see the maxExceeded and minExceeded. You need to change these to check if they equal 0 rather than > or < 0. For example:
                    Code:
                    maxExceeded = bars.Instrument.MasterInstrument.Compare(close, barMax) == 0 ? true : false;
                    minExceeded = bars.Instrument.MasterInstrument.Compare(close, barMin) == 0 ? true : false;
                    This is just what I see from the code. Please test this on your end.
                    Patrick H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Jschmelz, Today, 01:13 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post Jschmelz  
                    Started by Newtrader101, Today, 12:37 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post Newtrader101  
                    Started by shishir_nse, Today, 11:13 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post shishir_nse  
                    Started by shishir_nse, Today, 11:02 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post shishir_nse  
                    Started by 12VMan, Today, 07:15 AM
                    3 responses
                    18 views
                    0 likes
                    Last Post Lancer
                    by Lancer
                     
                    Working...
                    X