I tried looking at the C# info online, it say the precision is 7 digits....Any ideas?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 zstheorist, Today, 07:52 PM
|
0 responses
3 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
149 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
Comment