![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Certified NinjaScript Consultant
|
Just found out the strange issue:
Code:
#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.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
namespace NinjaTrader.Strategy
{
[Description("Enter the description of your strategy here")]
public class AAATest : Strategy
{
#region Variables
private DataSeries plot, plot1;
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
plot = new DataSeries(this);
plot1 = new DataSeries(this);
}
protected override void OnBarUpdate()
{
plot1.Set(5);
plot.Set(SMA(plot1, 5)[0]);
Print("** " + plot1[0] + " " + plot1[1] + " " + plot1[2] + " " + plot1[3] + " " + plot1[4] +" ** = Last 5 values of plot1");
Print(" ");
Print("-- " + plot[0] + " -- " + SMA(plot1, 5)[0] + " ---- == SMA(plot1, 5)[0]");
Print(" ");
Print(" ");
Print(" ");
Print(" ");
}
}
}
** 5 5 5 5 5 ** = Last 5 values of plot1 -- -388 ---388 ---- == SMA(plot1, 5)[0] ** 5 5 5 5 5 ** = Last 5 values of plot1 -- -389 ---389 ---- == SMA(plot1, 5)[0] ** 5 5 5 5 5 ** = Last 5 values of plot1 -- -390 ---390 ---- == SMA(plot1, 5)[0] Something is not right Thanks for looking |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
roonius, which market and timeframe did you test this on? On the TD 5min I get this output from exactly your code -
Code:
** 5 0 0 0 0 ** = Last 5 values of plot1 -- 1 -- 1 ---- == SMA(plot1, 5)[0] ** 5 5 0 0 0 ** = Last 5 values of plot1 -- 2 -- 2 ---- == SMA(plot1, 5)[0] ** 5 5 5 0 0 ** = Last 5 values of plot1 -- 3 -- 3 ---- == SMA(plot1, 5)[0] ** 5 5 5 5 0 ** = Last 5 values of plot1 -- 4 -- 4 ---- == SMA(plot1, 5)[0] ** 5 5 5 5 5 ** = Last 5 values of plot1 -- 5 -- 5 ---- == SMA(plot1, 5)[0] ** 5 5 5 5 5 ** = Last 5 values of plot1 -- 5 -- 5 ---- == SMA(plot1, 5)[0] ** 5 5 5 5 5 ** = Last 5 values of plot1 -- 5 -- 5 ---- == SMA(plot1, 5)[0]
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Certified NinjaScript Consultant
|
I tested on CL 10-09 1 tick.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Ok thanks roonius, which CalculateOnBarClose setting?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
roonius, finally I could see this on my end for 6.5.1000.12 - this will be fixed with NinjaTrader 7, thanks for posting this.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Certified NinjaScript Consultant
|
CalculateOnBarClose = true
|
|
|
|
|
|
#7 |
|
Certified NinjaScript Consultant
|
I thought that it only affects strategies, but...
Something changed in the recent releases - it brakes indicators and strategies which are using SMA and set to calculateonbarclose = false; attached code is totally stripped indicator which does not work when calculateonbarclose set to false. Code:
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;
namespace NinjaTrader.Indicator
{
[Description("Enter the description of your new custom indicator here")]
public class AAASMA : Indicator
{
private int period = 14; // Default setting for Period
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Magenta), PlotStyle.Line, "SmaPlot"));
CalculateOnBarClose = false;
Overlay = true;
PriceTypeSupported = true;
}
protected override void OnBarUpdate()
{
SmaPlot.Set(SMA(Input, Period)[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 SmaPlot
{
get { return Values[0]; }
}
[Description("")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
}
}
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
roonius, I'm not aware of changes in recent releaes - however the reported issue will be fixed with NinjaTrader 7
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Center Bars on Chart/Time (For Technical Programmer) | SharonSS | Suggestions And Feedback | 1 | 03-29-2009 04:47 AM |
| additional technical/programming documentation | tamas | General Programming | 6 | 01-22-2009 11:26 PM |
| Technical trading, strategy and how to about Time & Sales | alleillo | Miscellaneous Support | 2 | 11-29-2008 06:08 AM |
| Technical support | tedtm | Miscellaneous Support | 3 | 10-26-2006 12:21 PM |
| support | jplevandowski | Miscellaneous Support | 6 | 12-30-2005 01:55 AM |