![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
Hi, I am an experienced programmer, having done MT4 for several years (and C++ a long time ago).
I have a NT indicator I am trying to convert to MT, and wondered if someone would be willing to give me a couple tips on some base class members I do not understand. Hoping in the affirmative, I'll start with this: Inside the class are some member functions that look like this: [Browsable(false)] [XmlIgnore] public DataSeries aboveR1 { get { return base.Values[1]; } } [Browsable(false)] [XmlIgnore] public DataSeries aboveS1 { get { return base.Values[5]; } } [Browsable(false)] [XmlIgnore] public DataSeries belowR1 { get { return base.Values[2]; } } [Browsable(false)] [XmlIgnore] public DataSeries belowS1 { get { return base.Values[6]; } } [Browsable(false)] [XmlIgnore] public DataSeries midLOW { get { return base.Values[4]; } } [Browsable(false)] [XmlIgnore] public DataSeries midUP { get { return base.Values[3]; } } [Browsable(false)] [XmlIgnore] public DataSeries r2 { get { return base.Values[0]; } } [Browsable(false)] [XmlIgnore] public DataSeries s2 { get { return base.Values[7]; } } First off, I do not know what the "DataSeries" type returns exactly, and secondly what all the indexed "base.Values[]" mean. Could someone explain this to me please, or maybe if you can send me the definition of the base class I could figure it out (?) Thank you in advance! PS: If there is a link to a tutorial / manual that explains all this well, please don't hesitate to send :-) |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
Welcome to our forums here - for getting starting coding in the C# based NinjaScript, please consider reviewing those tutorials -
http://www.ninjatrader.com/support/h.../tutorials.htm Our DataSeries class is explained here - http://www.ninjatrader.com/support/h...ries_class.htm The Values one here - http://www.ninjatrader.com/support/h...nt7/values.htm For more advanced references samples and tips, please check into - http://www.ninjatrader.com/support/f...splay.php?f=29
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
Thank you for the links.
Have read over them a bit, especially the Values array / objects. Understand DataSeries now well enough... but when it references base.Values[?], still not sure what that would be referencing. Of course my mind is still trying to do a MT4 conversion :-) |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
The Values array is a collection holding the values calculated for the indicators, the plots added in the Initialize only determine how those should be visualized - this is basically the 'link' from the plot characteristics to the actual values plotted then.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Or am I not quite getting it? |
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
Those objects would hold double values.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
That's correct DerkWehler.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
muy gracias senior
Will see how far I can get on that. Appreciate the help. |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
Hello any readers:
Things are coming along. I think I am understanding much of the coding. But a brief question on this code snippet: protected override void OnBarUpdate() { double item; double num; double num1; if (base.CurrentBar == 0) { item = base.Close[0]; } else { item = base.Close[0] * 0.2 + 0.8 * base.Close[1]; } ... Unlike MT, which runs through a loop for each bar, I am assuming OnBarUpdate gets called for each bar on the chart..(?) So when it says: if (base.CurrentBar == 0) { item = base.Close[0]; } else { item = base.Close[0] * 0.2 + 0.8 * base.Close[1]; } Is that saying "if the bar we are working on is the open candle ("base.CurrentBar == 0" means the right-most open candle I assume, or is it the one that just closed?), then set: item = Close price of open (or most recently closed) candle else set item = Close price of right-most candle * 20% + Close price of previous candle * 80% --OR-- Does base.Close[0] here refer to the close of whatever candle we are working on? In other words, if OnBarUpdate is called for each candle, and the one it's currently working on is the 10th candle from the right, then does base.Close[0] refer to THAT candle, and base.Close[1] refer to the 11th candle from the right? PS: I am not sure how to get this editor to respect the tabs in my code when I paste it. Is there a trick? |
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
DerkWehler, glad to hear you're moving along nicely - OnBarUpdate() is called for each bar on the chart from left to right, so CurrentBar = 0 is the first bar on the left and not the rightmost one.
What Close[0] is depends on your CalculateOnBarClose setting for the script (for realtime processing) - http://www.ninjatrader.com/support/h...onbarclose.htm With this setting to 'true' you're processing the currently last closed candle, and not the developing right most one - this can only be accessed with 'false' and the [0] index. In this scenario then an index of [1] would mean the last completed candle. In backtesting / historical data this would always be 'true'.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#12 | |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
base.set_CalculateOnBarClose(true); So, calculating from the left, and it is on the 5th bar from the left at the moment, base.Close[0] refers to the close price of the current (5th from left) bar then? And base.Typical[1] refers to the previous (4th bar from left) bar's typical price, (high + low + close) / 3 ? Or does it refer to the 6th bar from the left? |
|
|
|
|
|
|
#13 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
You are correct in understanding, and index of 1 would mean one bar back. We would not supporting looking into the 'future' with indexing.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#14 | |
|
Junior Member
Join Date: Aug 2012
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Thanks again Bertrand! Probably will yet have a couple more questions, but that should get me translating most of it. :-) |
|
|
|
|
|
|
#15 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
You're welcome, best of luck on the conversions.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Performance tips? | trader2be | General Programming | 3 | 10-19-2010 06:21 AM |
| MT Predictor indicators | JOHNF1 | NinjaScript File Sharing Discussion | 20 | 07-19-2010 07:11 PM |
| Need tips for a strategy | barrosco | Miscellaneous Support | 2 | 02-20-2009 01:01 PM |
| some tips when using vista | qwert12 | Installation and Licensing | 1 | 06-30-2008 11:29 PM |
| A simple question from a new NT programmer | elemento-portador | Indicator Development | 1 | 11-05-2007 08:00 AM |