Add(Instrument.FullName,PeriodType.... ReversalBarsType - futures io
futures io



Add(Instrument.FullName,PeriodType.... ReversalBarsType


Discussion in NinjaTrader

Updated
    1. trending_up 3,519 views
    2. thumb_up 8 thanks given
    3. group 2 followers
    1. forum 19 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Add(Instrument.FullName,PeriodType.... ReversalBarsType

(login for full post details)
  #1 (permalink)
 pcomm69 
paris france
 
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
 
pcomm69's Avatar
 
Posts: 55 since Oct 2011
Thanks: 14 given, 4 received

Hi,

ReversalBarsType is well present in Data Series Type / ChartStyle
but dont appear in
Add(Instrument.FullName,PeriodType. .... (see the list)

It mean that
Add(Instrument.FullName,PeriodType.ReversalBarsType, 10); // [1]
is impossible.

Could you help me ?

Thanks
Pierre

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
TD Sequential for NT or MW?
Platforms and Indicators
Questioning Conventional Wisdom
Treasury Notes and Bonds
Experience with AGN (Introducing Broker)
Brokers
TradingView help in improving Anchored Vwap
Platforms and Indicators
Eurex Denali vs dxFeed
Sierra Chart
 
 
(login for full post details)
  #3 (permalink)
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received



pcomm69 View Post
Hi,

ReversalBarsType is well present in Data Series Type / ChartStyle
but dont appear in
Add(Instrument.FullName,PeriodType. .... (see the list)

It mean that
Add(Instrument.FullName,PeriodType.ReversalBarsType, 10); // [1]
is impossible.

Could you help me ?

Thanks
Pierre

I gather ReversalBars is some custom bar type you have imported to NT. The only way to add custom bar type is to use Custom or Final eg. assuming that ReversalBars use Custom5 you would use:
 
Code
Add(Instrument.FullName,PeriodType.Custom5, 10);
// or simply:
Add(PeriodType.Custom5, 10);
Check the code to see which PeriodType variable it is using.

Search for something similar to:
 
Code
public ReversalBarsType() : base(PeriodType.Custom5) { }

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #4 (permalink)
 pcomm69 
paris france
 
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
 
pcomm69's Avatar
 
Posts: 55 since Oct 2011
Thanks: 14 given, 4 received

Thanks for your help

here is the code decompiled
I don t find the good indication about
"public ReversalBarsType() : base(PeriodType.CustomX) { }"

#region Using declarations
using System;
using System.Collections;
using System.ComponentModel;
using System.Text;
#endregion

// This namespace holds all bars types. Do not change it.
namespace NinjaTrader.Data
{

/// <summary>
/// </summary>
public class ReversalBarsType: BarsType
{
private static bool registered = Data.BarsType.Register(new ReversalBarsType());

private bool OxFln4MCc;
private static bool VUHamLYRw;

/// <summary>
/// </summary>
/// <param name="bars"></param>
/// <param name="open"></param>
/// <param name="high"></param>
/// <param name="low"></param>
/// <param name="close"></param>
/// <param name="time"></param>
/// <param name="volume"></param>
/// <param name="isRealtime"></param>

#if NT7
public override void Add(Data.Bars bars, double open, double high, double low, double close, DateTime time,long volume, bool isRealtime)
#else
public override void Add(Data.Bars bars, double open, double high, double low, double close, DateTime time,int volume, bool isRealtime)
#endif
{


object[] objectArray1;
object[] objectArray2;
if (bars.Count == 0)
{
// base.AddBar (bars, open, high, low, close, time, volume);
AddBar(bars, open, high, low, close, time, volume,isRealtime);
this.OxFln4MCc = true;
return;
}
Bar bar1 = ((Bar) bars.Get (((int) (bars.Count - 1))));
double double1 = bars.Instrument.MasterInstrument.TickSize;
double double2 = (Math.Floor (((10000000D * ((double) bars.Period.Value)) * double1)) / 10000000D);
if ((! this.OxFln4MCc) && (bars.Instrument.MasterInstrument.Compare (close, (bar1.Low + double2)) >= 0))
{
objectArray1 = new object[] { close, (bar1.Low + double2), double2 };
this.OxFln4MCc = true;
// base.AddBar (bars, close, close, close, close, time, 0);
AddBar(bars, close, close, close, close, time, 0,isRealtime);
}
else if (this.OxFln4MCc && (bars.Instrument.MasterInstrument.Compare ((bar1.High - double2), close) >= 0))
{
objectArray2 = new object[] { close, (bar1.High - double2), double2 };
this.OxFln4MCc = false;
// base.AddBar (bars, close, close, close, close, time, 0);
AddBar(bars, close, close,close, close, time, 0,isRealtime);
}
else
{
UpdateBar(bars, open, high, low, close, time, volume,isRealtime);
}
}

#if NT7
/// <summary>
/// </summary>
/// <param name="barsData"></param>
public override void ApplyDefaults(Gui.Chart.BarsData barsData)
{
barsData.DaysBack = 5;
barsData.Period.Value = 5;
}
#endif
/// <summary>
/// </summary>
public override PeriodType BuiltFrom
{
get { return PeriodType.Tick; }
}

/// <summary>
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public override string ChartDataBoxDate(DateTime time)
{
return time.ToString(Cbi.Globals.CurrentCulture.DateTimeFormat.ShortDatePattern);
}

/// <summary>
/// </summary>
/// <param name="chartControl"></param>
/// <param name="time"></param>
/// <returns></returns>
public override string ChartLabel(NinjaTrader.Gui.Chart.ChartControl chartControl, DateTime time)
{
return time.ToString(chartControl.LabelFormatSecond, Cbi.Globals.CurrentCulture);
}


#if NT7
/// <summary>
/// Here is how you restrict the selectable chart styles by bars type
/// </summary>
public override Gui.Chart.ChartStyleType[] ChartStyleTypesSupported
{
get { return new Gui.Chart.ChartStyleType[] { Gui.Chart.ChartStyleType.Box, Gui.Chart.ChartStyleType.CandleStick, Gui.Chart.ChartStyleType.HiLoBars, Gui.Chart.ChartStyleType.LineOnClose,
Gui.Chart.ChartStyleType.OHLC, Gui.Chart.ChartStyleType.Custom0, Gui.Chart.ChartStyleType.Custom1, Gui.Chart.ChartStyleType.Custom2, Gui.Chart.ChartStyleType.Custom3,
Gui.Chart.ChartStyleType.Custom4, Gui.Chart.ChartStyleType.Custom5, Gui.Chart.ChartStyleType.Custom6, Gui.Chart.ChartStyleType.Custom7, Gui.Chart.ChartStyleType.Custom8,
Gui.Chart.ChartStyleType.Custom9, Gui.Chart.ChartStyleType.Final0, Gui.Chart.ChartStyleType.Final1, Gui.Chart.ChartStyleType.Final2, Gui.Chart.ChartStyleType.Final3,
Gui.Chart.ChartStyleType.Final4 }; } }
#endif

/// <summary>
/// </summary>
/// <returns></returns>
public override object Clone()
{
return new ReversalBarsType ();
}
#if !NT7
/// <summary>
/// </summary>
public override int DaysBack
{
get { return Gui.Chart.ChartData.DaysBackTick; }
}
#endif

/// <summary>
/// </summary>
public override int DefaultValue
{
get { return 5; }
}

/// <summary>
/// </summary>
public override string DisplayName
{
get { return "ReversalBarsType"; }
}

#if !NT7
/// <summary>
/// </summary>
public override bool IsTimeBased
{
get { return false; }
}

/// <summary>
/// </summary>
public override int MaxLookBackDays
{
get { return 10;}
}

/// <summary>
/// </summary>
public override int MaxValue
{
get { return -1; }
}
#endif

#if NT7
/// <summary>
/// </summary>
/// <param name="period"></param>
/// <param name="barsBack"></param>
/// <returns></returns>
public override int GetInitialLookBackDays(Period period, int barsBack)
{
return 1;
}
#endif

/// <summary>
/// </summary>
public override double GetPercentComplete(Data.Bars bars, DateTime now)
{
return Math.Abs((double)bars.Period.Value);

}

/// <summary>
/// </summary>
/// <param name="propertyDescriptor"></param>
/// <param name="period"></param>
/// <param name="attributes"></param>
/// <returns></returns>
#if NT7
public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes)
{
PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes);

// here is how you remove properties not needed for that particular bars type
properties.Remove(properties.Find("BasePeriodType", true));
properties.Remove(properties.Find("BasePeriodValue", true));
properties.Remove(properties.Find("PointAndFigurePriceType", true));
properties.Remove(properties.Find("ReversalType", true));
properties.Remove(properties.Find("Value2", true));

// here is how you change the display name of the property on the properties grid
Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "\rRev Bar Size");

return properties;
}
#endif

#if !NT7
/// <summary>
/// </summary>
public override int SortOrder
{
get { return 15000; }
}
#endif
/// <summary>
/// </summary>
public override bool IsIntraday
{
get { return true; }
}

/// <summary>
/// </summary>
/// <param name="period"></param>
/// <returns></returns>
public override string ToString(Period period)
{
return "ReversalBarsType " + period.Value.ToString();
}

/// <summary>
/// </summary>
public ReversalBarsType () : base(PeriodType.Custom4)
{
this.OxFln4MCc = true;
}

static ReversalBarsType ()

{
ReversalBarsType.VUHamLYRw = BarsType.Register (((BarsType) new ReversalBarsType ()));
}
}
}

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received


pcomm69 View Post
Thanks for your help

here is the code decompiled
I don t find the good indication about
"public ReversalBarsType() : base(PeriodType.CustomX) { }"

You had it at the bottom:
 
Code
		/// <summary>
		/// </summary>
		public ReversalBarsType () : base(PeriodType.Custom4)
		{
			this.OxFln4MCc = true;
		}
So use Custom4 to add the bar type.

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #6 (permalink)
 pcomm69 
paris france
 
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
 
pcomm69's Avatar
 
Posts: 55 since Oct 2011
Thanks: 14 given, 4 received

Oups !
Thanks
The compilation is good
but the execution in UT2 dont works
Have you an idea ?
in UT 2 :

protected override void Initialize()
{
Add(Instrument.FullName,PeriodType.Custom4, 10);// [1]
CalculateOnBarClose = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (BarsInProgress == 1 && (CurrentBar >=1))
{
DrawTextFixed("tag1", " ", TextPosition.TopRight); /// on efface le message
DrawTextFixed("tag1", (Opens[1][1]).ToString(), TextPosition.TopRight);
}
}

Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received


pcomm69 View Post
Oups !
Thanks
The compilation is good
but the execution in UT2 dont works
Have you an idea ?
in UT 2 :

What is UT2?

Try adding without the Instrument.FullName, ie:
 
Code
Add(PeriodType.Custom4, 10);// [1]
Also for better debugging add Print method to check in the output window if it executes:
 
Code
        protected override void OnBarUpdate()
        {
          if (BarsInProgress == 1) 
		{		
                     Print("inside secondary bars");	
                }
        }
Check for any errors in the output window and log tab of Control Center and let me know if it says something.

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #8 (permalink)
 pcomm69 
paris france
 
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
 
pcomm69's Avatar
 
Posts: 55 since Oct 2011
Thanks: 14 given, 4 received

it say nothing
it is mute

THE LOG SAY : ERROR ON CALLING OnBarUpDate on bar 0 Bar Index Need

try it in Chart 2 min (UT 2 min)

protected override void Initialize()
{
Add(Instrument.FullName,PeriodType.Custom4, 10);// [1]
CalculateOnBarClose = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
{
Print("inside secondary bars");
}
}

Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
 pcomm69 
paris france
 
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
 
pcomm69's Avatar
 
Posts: 55 since Oct 2011
Thanks: 14 given, 4 received

THE LOG SAY : ERROR ON CALLING OnBarUpDate on bar 0. Bar Index Needs

Started this thread Reply With Quote
 
(login for full post details)
  #10 (permalink)
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received



pcomm69 View Post
THE LOG SAY : ERROR ON CALLING OnBarUpDate on bar 0. Bar Index Needs

I think the error message is cutoff - can you scroll to the right to get a full one?

Reply With Quote
The following user says Thank You to gregid for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Add(Instrument.FullName,PeriodType.... ReversalBarsType


Last Updated on April 28, 2015


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing

Your Charts Should Speak To You w/Bob Cometta

Elite only
 

Our 12-year anniversary w/ $$,$$$ prizes (check soon)

August
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts