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



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


Discussion in NinjaTrader

Updated
    1. trending_up 3,362 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)
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

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(169 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
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)
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)
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)
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)
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)
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)
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)
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:
 
(login for full post details)
  #11 (permalink)
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 sorry for the mistake
THE LOG SAY : ERROR ON CALLING OnBarUpDate on bar 0. Bar Index Needs to be grather or egal to 0

Started this thread Reply With Quote
 
(login for full post details)
  #12 (permalink)
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 sorry for the mistake
THE LOG SAY : ERROR ON CALLING OnBarUpDate on bar 0. Bar Index Needs to be grather or egal to 0

OK, please try the minimum version with just adding the bar and Print method (no DrawText...) just as in my post - trying to identify where the error is.

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #13 (permalink)
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

I am reback excuse me
nothing in log
but "inside secondary bars" in the output windows
first step is good

protected override void Initialize()
{

Add(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)
  #14 (permalink)
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
I am reback excuse me
nothing in log
but "inside secondary bars" in the output windows
first step is good

Now we know that the secondary bars have been successfully added and the error was in your DrawText.

If you are inside BarsInProgress == 1 you can use Open[X] and this will use the right Bars, so your DrawText can be:
 
Code
DrawTextFixed("tag1", Open[1].ToString(), TextPosition.TopRight);

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #15 (permalink)
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

if i try this
protected override void Initialize()
{
Add(PeriodType.Custom4, 20);// [1]
CalculateOnBarClose = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if ((BarsInProgress == 1) && (CurrentBar > 1))
{
Print((Opens[1][3]));
}
}

the answer in output windows is :
Error on calling 'OnBarUpdate' method for indicator 'BackGroundRBT' on bar 2: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


for me the probleme is on the history of bar for Series 1 in Custom 4

Started this thread Reply With Quote
 
(login for full post details)
  #16 (permalink)
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 answer in output windows is :
Error on calling 'OnBarUpdate' method for indicator 'BackGroundRBT' on bar 2: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


for me the probleme is on the history of bar for Series 1 in Custom 4

The problem is you don't have enough bars available - you are requesting data from 4 bars ago (3) while on bar 0, 1, 2. This won't work so you need to make sure that:
 
Code
if (CurrentBars[1] < X) return;
where x is the minimum bars you will require for calculation in the above case X will be 4.

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #17 (permalink)
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

I am so so sorry

I dont know if CurrentBars[1] >30
witch work

I have used
if ((BarsInProgress == 1) && (CurrentBar > 30)) {do something}
withch dont work

what is the difference ?

Thanks

Started this thread Reply With Quote
 
(login for full post details)
  #18 (permalink)
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
I am so so sorry

I dont know if CurrentBars[1] >30
witch work

I have used
if ((BarsInProgress == 1) && (CurrentBar > 30)) {do something}
withch dont work

what is the difference ?

Thanks

Hard to say, theoretically both should work, but just in case when using multiple bars series always use CurrentBars[x]

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #19 (permalink)
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

I note it
Thank you so much for your help

Started this thread Reply With Quote
 
(login for full post details)
  #20 (permalink)
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
I note it
Thank you so much for your help

You're welcome

Reply With Quote


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
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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