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
Trying to get a Percentage
Collapse
X
-
Leave a comment:
-
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...
i guess is the only way to learn
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:
-
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:
-
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:
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:
Code:if(signalOne + signalTwo != 0)[B] double [/B]percentage= ( (signalTwo* 100 ) / signalSum)
Leave a comment:
-
Originally posted by kabott View Postreturn!! XD thanks man! im so dumb!!
Code:double percentage= 0.0; if (signalTwo != 0) percentage= ( (signalSum* 100 ) / signalTwo); else return;
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:
-
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 helpLast edited by kabott; 09-08-2014, 08:41 PM.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
21 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
10 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Leave a comment: