Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Add(Instrument.FullName,PeriodType.... ReversalBarsType
Updated April 28, 2015
trending_up
5,492 views
thumb_up
8 thanks given
group
2 followers
forum
19 posts
attach_file
0 attachments
Add(Instrument.FullName,PeriodType.... ReversalBarsType
April 28th, 2015, 08:29 AM
paris france
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
Posts: 55 since Oct 2011
Thanks Given: 14
Thanks Received: 4
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
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
April 28th, 2015, 09:06 AM
Wrocław, Poland
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623
pcomm69
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) { }
April 28th, 2015, 09:32 AM
paris france
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
Posts: 55 since Oct 2011
Thanks Given: 14
Thanks Received: 4
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 ()));
}
}
}
April 28th, 2015, 09:38 AM
Wrocław, Poland
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623
pcomm69
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.
April 28th, 2015, 11:07 AM
paris france
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
Posts: 55 since Oct 2011
Thanks Given: 14
Thanks Received: 4
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);
}
}
April 28th, 2015, 11:24 AM
Wrocław, Poland
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623
pcomm69
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.
April 28th, 2015, 11:39 AM
paris france
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
Posts: 55 since Oct 2011
Thanks Given: 14
Thanks Received: 4
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");
}
}
April 28th, 2015, 11:43 AM
paris france
Experience: Advanced
Platform: NinjaTrader
Broker: Continuum
Trading: gold & crude light
Posts: 55 since Oct 2011
Thanks Given: 14
Thanks Received: 4
THE LOG SAY : ERROR ON CALLING OnBarUpDate on bar 0. Bar Index Needs
April 28th, 2015, 11:45 AM
Wrocław, Poland
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623
pcomm69
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?
Last Updated on April 28, 2015