Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trying to get a Percentage
Collapse
X
-
Leave a comment:
-
For some reason, your attachments are invalid?Originally posted by kabott View PostHi koganam, yes, but i realize i it was wrong when i wrote the post, i guess i was tired, it was late in the night.. but anyways your reply helped me fix the problem!
the intention for this percentage was to create some sort of Market Analizer that would help me decide which markets are best for Renko trading, meaninge less chopy, you can see in the image below two examples, on the EURAUD you have the double amount of bars than the EURCAD and yet is more advisable to trade
[ATTACH]29994[/ATTACH]
basically what im doing is multiplying the amount of bars by 100, and then diving it by the amount of fractals or "trend change", the result would be the "Smoothness factor"
Then to calculate the size of movement, "swing range" i take Highest Highs from the last 200 periods and subtract the Lowest Lows of the same periods, the same with 100 and 50 periods, add em all up, divide by 3 and multiply by ATR, this should gave me an idea of the total movement the currency did during this period.
finally multiply the swing range by the smoothness factor, i divide the result by 10 to get a small number i can easily comprehend
I wanted to create a tool that would help me decide each day what currency to trade, the highest the number the better conditions, i know past performance isn't indicative of future performance, but it helps, some currencies are by nature more choppy than others.
I did the same thing with a supertrend and daily charts, to see which markets where more predictable than others, by "predictable" i mean, which ones respect the super trend levels more times before braking it and changing trend..it helps.
any ways, "maths force isnt strong in me" im a graphic designer, dont even know C# well, just copy & paste work, im learning in the process, here's the indi, i intended to create a Ninja Market Sentiment Chart but dunno why does't work there. numbers are not the same shown in the bar chart windows.
[ATTACH]29995[/ATTACH]
I get the idea of your code. Have you found it useful, truly? It might be worth looking into, just to get the coding right.
Leave a comment:
-
In fact, Ninja now won't let me work on code if it's later than 10pm... lol...
..
LOL
i guess is the only way to learn
Thanks arbuthnot, my creative side has always been my strongest side, but over these fields i feel like the old proverbial Penguin in the Desert, lolIt's good to see an 'arts' person playing with math and code. Keep up the good work ... you've got some neat ideas
Leave a comment:
-
Thanks, Kabott!
I'm glad to see you've got that sorted out.
It's getting late here (I'm on the other side of the Pond if you're in the US) so I won't have a detailed look tonight. If you knew the mistakes I have made by working on Ninja into the early hours...
In fact, Ninja now won't let me work on code if it's later than 10pm... lol...
It's good to see an 'arts' person playing with math and code. Keep up the good work ... you've got some neat ideas.
Leave a comment:
-
Hi arbuthnot, yes you r right, it was late at night and i wasn't thinking clearly, i just wanted to post the question and head for bed lol, anyways this is how the equation ended up:
double t3totalCount= (risingSig + fallingSig); // Fractal count
if ( t3totalCount==0 ) return;
{
t3AverageSmoothness=( ((CurrentBar * 100) / t3totalCount) /100 ); // the last division by 100 is just to get a smaller number.
}
feel free to download the indicator & play with it, my math skills r very limited, im an "arts" guy .. lol
Leave a comment:
-
Hi koganam, yes, but i realize i it was wrong when i wrote the post, i guess i was tired, it was late in the night.. but anyways your reply helped me fix the problem!That code is based entirely on what you said that you want to do. As I do not know your bigger purpose, I cannot comment about the viability of your approach
the intention for this percentage was to create some sort of Market Analyzer that would help me decide which markets are best for Renko trading, meaninge less choppy, you can see in the image below two examples, on the EURAUD you have the double amount of bars than the EURCAD and yet is more advisable to trade
basically what im doing is multiplying the amount of bars by 100, and then diving it by the amount of fractals or "trend change", the result would be the "Smoothness factor"
Then to calculate the size of movement, "swing range" i take Highest Highs from the last 200 periods and subtract the Lowest Lows of the same periods, the same with 100 and 50 periods, add em all up, divide by 3 and multiply by ATR, this should gave me an idea of the total movement the currency did during this period.
finally multiply the swing range by the smoothness factor, i divide the result by 10 to get a small number i can easily comprehend
I wanted to create a tool that would help me decide each day what currency to trade, the highest the number the better conditions, i know past performance isn't indicative of future performance, but it helps, some currencies are by nature more choppy than others.
I did the same thing with a supertrend and daily charts, to see which markets where more predictable than others, by "predictable" i mean, which ones respect the super trend levels more times before braking it and changing trend..it helps.
any ways, "maths force isn't strong in me" im a graphic designer, don't even know C# well, just copy & paste work, im learning in the process, here's the indi, i intended to create a Ninja Market Analyzer Chart but dunno why doesn't work there. numbers are not the same shown in the bar chart windows.
Last edited by kabott; 09-13-2014, 04:57 PM.
Leave a comment:
-
Hi Kabott
Firstly, always listen to Koganam - his expertise is out of the top drawer!
Secondly, and please correct me if I'm wrong, I think you might have missed something at the very beginning.
In your first post, you put:
Ignoring the multiplier (= 100), your percentage equation is effectively:Code:int signalSum=( signalOne + signalTwo); int percentage= ( (signalSum* 100 ) / signalTwo);
(signalOne + signalTwo)
-----------------------------------
signalTwo
As these three numbers are positive, this will give you a fraction greater than 1 - or a percentage greater than 100.
I think you should have made this your equation:
signalTwo
---------------------------------
(signalOne + signalTwo)
so your percentage variable would be:
Hope this helps.Code:if(signalOne + signalTwo != 0)[B] double [/B]percentage= ( (signalTwo* 100 ) / signalSum)
Leave a comment:
-
Not so dumb. You will not believe how many times that I still make the mistake.Originally posted by kabott View Postreturn!! XD thanks man! im so dumb!!
You probably do not want to evaluate percentage as an integer.Code:double percentage= 0.0; if (signalTwo != 0) percentage= ( (signalSum* 100 ) / signalTwo); else return;
Which may also mean that you have to cast your counts to doubles before doing the division.
That code is based entirely on what you said that you want to do. As I do not know your bigger purpose, I cannot comment about the viability of your approach.Last edited by koganam; 09-09-2014, 10:11 AM.
Leave a comment:
-
You have to decide what you want to do if signalTwo is zero, then code that action. What do you want to do if signalTwo is zero?Originally posted by kabott View PostHi koganam, yes thats what the Log says:
"Attempted to divide by zero."
but how do i solve it?Last edited by koganam; 09-09-2014, 09:15 AM.
Leave a comment:
-
Originally posted by kabott View PostHi, im trying to get a percentage between 2 counts but isn't working, the indicator just disappears at F5
so, this is what im doing:
if ( XXX > XXX)
{
signalOne++;
}
if (XXXX XXX)
{
signalTwo++;
}
int signalSum=( signalOne + signalTwo);
int percentage= ( (signalSum* 100 ) / signalTwo);
DrawTextFixed( XXXXXXX, percentage.ToString() , XXXXXXX)
the sum works fine, the percentage doesn't, what im doing wrong?
ill appreciate any help
- What is the error in your log?
- You have not taken care of a possible division by zero.
Leave a comment:
-
Trying to get a Percentage
Hi, im trying to get a percentage between 2 counts but isn't working, the indicator just disappears at F5
so, this is what im doing:
if ( XXX > XXX)
{
signalOne++;
}
if (XXXX XXX)
{
signalTwo++;
}
int signalSum=( signalOne + signalTwo);
int percentage= ( (signalSum* 100 ) / signalTwo);
DrawTextFixed( XXXXXXX, percentage.ToString() , XXXXXXX)
the sum works fine, the percentage doesn't, what im doing wrong?
ill appreciate any help
Last edited by kabott; 09-08-2014, 08:41 PM.Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
152 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
89 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
131 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
127 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Leave a comment: