|
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
The problem with programming UniRenkoBars
Collapse
X
-
Because if you read the source code for the UniRenko bar type, which is located in bin/Custom/Type/UniRenkoBarsType.cs, that's how you do it.
There is very specific code in that file that will decode that large single combined parameter into its 3 constituent small parameters.
Go find it.
- Likes 1
Comment
-
Yes, I found it. With it, I figured out that it is called as Custom 5. And just saw that there are three parameters, but why 004008002, not 4, 8, 2Originally posted by bltdavid View Post
Because if you read the source code for the UniRenko bar type, which is located in bin/Custom/Type/UniRenkoBarsType.cs, that's how you do it.
There is very specific code in that file that will decode that large single combined parameter into its 3 constituent small parameters.
Go find it.
Comment
-
Because the Add() method has no overload accepting those 3 integer parameters.Originally posted by Kovalev View Post
Yes, I found it. With it, I figured out that it is called as Custom 5. And just saw that there are three parameters, but why 004008002, not 4, 8, 2
So, whereas the BarType programmer can create a new bar type and force the Data Series dialog to accept 3 parameters, there were no work-aounds to make Add() accept 3 parameters, since that kind of change would have to come from NinjaTrader programmers internally.
Thus, the designer of UniRenko had to get very creative. Many people wanted to use his UniRenko bars programmatically, but there was no way to specify the required 3 parameters.
What to do?
What to do?
Well, he got to thinking.
What if he created a specially encoded single parameter that contained all 3 numbers organized in a very specific way, so that he could decode that huge-ish number back into 3 small numbers, and do that decoding on the very first bar of the chart?
Ok, how does it work, you ask?
Say you wanted a 2-6-3 UniRenko chart.
The BarInterval parameter is calculated like this,
which you pass to Add(), via normal,Code:int BarInterval = 2*1000000 + 6*1000 + 3;
And that, combined with the code you found to decode it, is why it works.Code:Add(PeriodType.Custom5, BarInterval);
So, why he had to do it this way was because there was no official way to do it.
He had to use the raw language ability of C# to invent something to workaround the lack of foresight & functionality provided by NinjaTrader's limited Add() method. Because he only had one integer parameter to work with.
He had to get very clever.
Necessity was the mother of invention.
Make sense?
PS:
The whole ordeal and subsequent solution is chronicled fairly well at BigMike's -- which is now at http://www.futures.io.Last edited by bltdavid; 12-24-2018, 07:14 AM.
- Likes 1
Comment
-
While this is a valid way to do it there are at least two other ways to do this where digit parsing is not needed. you can use just the integer values. Sadly, because this is how I make my living, no free code examples.
Comment
-
Yes, there are other ways. They are not as secret as you imply.Originally posted by RJay View PostWhile this is a valid way to do it there are at least two other ways to do this where digit parsing is not needed. you can use just the integer values. Sadly, because this is how I make my living, no free code examples.
A code sample is straight forward, RJay, nothing earth-shattering ...
For example,
should set up the same 2-6-3 UniRenko chart.Code:protected override void Initialize() { Add(PeriodType.Custom5, 2); if (BarsPeriods.Length > 0) { BarsPeriods[BarsPeriods.Length-1].Value2 = 6; BarsPeriods[BarsPeriods.Length-1].BasePeriodValue = 3; } }
- Likes 1
Comment
-
Do you work for free? I have bills that need to be paid. I never said anything about it being a "Secret". Your code would not be my first choice but if it works terrific, thank you for sharing.
Comment
-
Thanks, RJay, I respect your work
However, if you felt unable to really contribute to the discussion, then why did you reply at all?
I mean, your first comment was a bit odd of sorts, as it added absolutely nothing to the core of
public knowledge ... I mean, zero, bud, ... nada, zilch ... that's not like you. So, why reply at all?
I mean, your saying "I have other ways, but sorry, I won't show you" is a bit pointless, don't you think?
Did I miss something?
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
569 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment