|
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
The problem with programming UniRenkoBars
Collapse
X
-
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
-
Originally 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
-
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,
Code:int BarInterval = 2*1000000 + 6*1000 + 3;
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
-
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,
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 traderqz, Today, 09:44 AM
|
2 responses
4 views
0 likes
|
Last Post Today, 10:00 AM | ||
Started by stafe, 04-15-2024, 08:34 PM
|
8 responses
40 views
0 likes
|
Last Post
by stafe
Today, 10:00 AM
|
||
Started by rocketman7, Today, 09:41 AM
|
2 responses
6 views
0 likes
|
Last Post
by rocketman7
Today, 09:52 AM
|
||
Started by rocketman7, Today, 02:12 AM
|
7 responses
31 views
0 likes
|
Last Post Today, 09:23 AM | ||
Started by guillembm, Yesterday, 11:25 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 09:11 AM |
Comment