NexusFi: Find Your Edge


Home Menu

 





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


Discussion in NinjaTrader

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




 
Search this Thread

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

  #1 (permalink)
 
pcomm69's Avatar
 pcomm69 
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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
32 thanks
Just another trading journal: PA, Wyckoff & Trends
26 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
19 thanks
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623



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
Thanked by:
  #4 (permalink)
 
pcomm69's Avatar
 pcomm69 
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 ()));
}
}
}

Started this thread Reply With Quote
  #5 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


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
Thanked by:
  #6 (permalink)
 
pcomm69's Avatar
 pcomm69 
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);
}
}

Started this thread Reply With Quote
  #7 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


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
Thanked by:
  #8 (permalink)
 
pcomm69's Avatar
 pcomm69 
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");
}
}

Started this thread Reply With Quote
  #9 (permalink)
 
pcomm69's Avatar
 pcomm69 
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

Started this thread Reply With Quote
  #10 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623



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
Thanked by:




Last Updated on April 28, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts