I tried looking at the C# info online, it say the precision is 7 digits....Any ideas?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Number truncated?
Collapse
X
-
Number truncated?
I am trying to input the number 0.000055 into an indicator. The variable type in the indicator is double. The indicator is "rounding" the number to 0.0001.
I tried looking at the C# info online, it say the precision is 7 digits....Any ideas?Tags: None
-
I am posting just the first part of the indicator, not the ninja generated part
The value for the Multiplier in the variables section is the value in question
I added code to produce the print statements down just below where the period is determined in the OnBarUpdate section
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
[Description("Enter the description of your new custom indicator here")]
public class AdaptiveSuperTrend2 : Indicator
{
#region Variables
// Wizard generated variables
private double multiplier = 0.5; // Default setting for Multiplier
private bool showArrows = true;
// User defined variables (add any user defined variables below)
private BoolSeries Trend;
private DataSeries oscillator;
// private DataSeries TrendDown;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Green, PlotStyle.Line, "UpTrend"));
Add(new Plot(Color.Red, PlotStyle.Line, "DownTrend"));
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
Trend = new BoolSeries(this);
oscillator = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
if (CurrentBar < 20)
{
Trend.Set(true);
UpTrend.Set (Close[0]);
DownTrend.Set(Close[0]);
return;
}
if (Close[0]>DownTrend[1]){
Trend.Set(true);
}else{
if (Close[0]<UpTrend[1]){
Trend.Set(false);
}else{
Trend.Set(Trend[1]);
}
}
double period = HomodyneDiscriminator(Median)[0];
Print("Time"+Time[0]);
Print("Period="+period);
Print("Multi="+Multiplier);
if(Trend[0] && !Trend[1])
{
UpTrend.Set(Median[0] - period*Multiplier);
UpTrend.Set(1, DownTrend[1]);
if (ShowArrows){
DrawArrowUp(CurrentBar.ToString(), true, 0, UpTrend[0] - TickSize, Color.Blue);
}
} else
if (!Trend[0] && Trend[1])
{
DownTrend.Set(Median[0] + period*Multiplier);//
DownTrend.Set(1, UpTrend[1]);
if (ShowArrows){
DrawArrowDown(CurrentBar.ToString(), true, 0, DownTrend[0] + TickSize, Color.Red);
}
} else
if (Trend[0]){
double si = period*Multiplier;
// this.HomodyneDiscriminator(Close)[0]*Multiplier;
UpTrend.Set((Median[0] - si) > UpTrend[1] ? (Median[0] - si) : UpTrend[1]);
Oscillator.Set(1.0);
}else{
//double si = this.HomodyneDiscriminator(Close)[0]*Multiplier;
double si = period*Multiplier;
DownTrend.Set((Median[0] + si) < DownTrend[1] ? (Median[0] + si) : DownTrend[1]);
Oscillator.Set(0.0);
}
//Print(UpTrend[0] + ", " + DownTrend[0] + ", " + Trend[0] + ", " + Close[0] + "");
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries UpTrend
{
get { return Values[0]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries DownTrend
{
get { return Values[1]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Oscillator
{
get { return oscillator; }
}
/*
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public BoolSeries Trend
{
get { return Trend; }
}
*/
[Description("Show Arrows when Trendline is violated")]
[Category("Parameters")]
public bool ShowArrows
{
get { return showArrows; }
set { showArrows = value; }
}
[Description("Period Multiplier")]
[Category("Parameters")]
public double Multiplier
{
get { return multiplier; }
set { multiplier = Math.Max(0.0001, value); }
}
#endregion
}
}
Comment
-
[Description("Period Multiplier")]
[Category("Parameters")]
public double Multiplier
{
get { return multiplier; }
set { multiplier = Math.Max(0.0001, value); }
}
You are setting it to take the max of the value you set or 0.0001. If you try to use a value less than that it will automatically go to 0.0001.Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by sjsj2732, Yesterday, 04:31 AM
|
0 responses
33 views
0 likes
|
Last Post
by sjsj2732
Yesterday, 04:31 AM
|
||
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
286 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
284 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
133 views
1 like
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
91 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|

Comment