NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 08-26-2009, 01:00 PM   #1
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 3 times in 3 posts
Send a message via Skype™ to roonius
Default To technical support

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(" ");
        }

    }
}
Output:

** 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
roonius is offline  
Reply With Quote
Old 08-26-2009, 01:32 PM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

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]
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-26-2009, 01:39 PM   #3
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 3 times in 3 posts
Send a message via Skype™ to roonius
Default

I tested on CL 10-09 1 tick.
roonius is offline  
Reply With Quote
Old 08-26-2009, 01:54 PM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Ok thanks roonius, which CalculateOnBarClose setting?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-26-2009, 02:03 PM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

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.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-26-2009, 02:07 PM   #6
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 3 times in 3 posts
Send a message via Skype™ to roonius
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Ok thanks roonius, which CalculateOnBarClose setting?
CalculateOnBarClose = true
roonius is offline  
Reply With Quote
Old 08-27-2009, 02:09 PM   #7
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 3 times in 3 posts
Send a message via Skype™ to roonius
Default

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); }
        }
    }
}
roonius is offline  
Reply With Quote
Old 08-27-2009, 02:27 PM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

roonius, I'm not aware of changes in recent releaes - however the reported issue will be fixed with NinjaTrader 7
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 07:47 PM.