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
A very simple question for programmers
Collapse
X
-
Originally posted by pstrusi View PostKoganan in my backtesting I'd need to compare 2 values like differences between average, therefore I have two questions in order to find the best solution:
1. The best way could be using for example:
if (Instrument.MasterInstrument.Compare(Price1, Price2) == 1)
2. Or can I format double values to a fix format, for example: round to 0.000000 format but not necessarily divisible exactly by ticksize ?
Thanks for all inputs my friends
That mathematical puritanism aside, yes you can round to any value you want. There is the C# Math.Round() function. ref: http://msdn.microsoft.com/en-us/library/75ks3aby.aspxLast edited by koganam; 06-03-2012, 05:24 PM.
Leave a comment:
-
Originally posted by koganam View PostCode:double ComparisonValue = Close[0]-(Close[0]+Open[0])/2; if (Instrument.MasterInstrument.Round2TickSize(ComparisonValue) == 0.000175) { //MakeMegaBucks(); }
It seems to me that you may be better off multiplying both sides by a suitable factor, such as 1000, so that you are comparing values of like accuracy, or else mathematically rounding to 6 decimal places, which will allow a match if, and only if, the instrument has a tickSize to 5 decimal places, and the range of the candle is exactly 0.00035.
Edit: As a matter of fact, writing
Code:if ((Close[0] - Open[0]) == 0.00035) ...
Leave a comment:
-
Originally posted by koganam View PostCode:double ComparisonValue = Close[0]-(Close[0]+Open[0])/2; if (Instrument.MasterInstrument.Round2TickSize(ComparisonValue) == 0.000175) { //MakeMegaBucks(); }
One day there will be a slip up.
Leave a comment:
-
Koganan in my backtesting I'd need to compare 2 values like differences between average, therefore I have two questions in order to find the best solution:
1. The best way could be using for example:
if (Instrument.MasterInstrument.Compare(Price1, Price2) == 1)
2. Or can I format double values to a fix format, for example: round to 0.000000 format but not necessarily divisible exactly by ticksize ?
Thanks for all inputs my friends
Leave a comment:
-
Originally posted by pstrusi View PostI meant those format values ( 6 digits after 0 ), I didn't understand how the round off will work out with it
Thanks Koganan, I'll try it that way; this is embarrassing cause it should be pretty easy to solveCode:double ComparisonValue = Close[0]-(Close[0]+Open[0])/2; if (Instrument.MasterInstrument.Round2TickSize(ComparisonValue) == 0.000175) { //MakeMegaBucks(); }
It seems to me that you may be better off multiplying both sides by a suitable factor, such as 1000, so that you are comparing values of like accuracy, or else mathematically rounding to 6 decimal places, which will allow a match if, and only if, the instrument has a tickSize to 5 decimal places, and the range of the candle is exactly 0.00035.
Edit: As a matter of fact, writing
Code:if ((Close[0] - Open[0]) == 0.00035) ...
Last edited by koganam; 06-03-2012, 05:17 PM.
Leave a comment:
-
I meant those format values ( 6 digits after 0 ), I didn't understand how the round off will work out with it
Thanks Koganan, I'll try it that way; this is embarrassing cause it should be pretty easy to solve
Leave a comment:
-
Originally posted by pstrusi View PostThanks Koganan but I'd need to work with those values, so what others ways are there?
Leave a comment:
-
Thanks Koganan but I'd need to work with those values, so what others ways are there?
Leave a comment:
-
Originally posted by pstrusi View PostI apologize for my programming ignorance but I'm stuck in something that it shouldn't happen
I'm testing a very simple condition:
if ( (Close[0]-(Close[0]+Open[0])/2) < -0.000175)
{
EnterShort(100000, "SELL");
}
I work with Range bars, onBarUpdate=true....ect etc
The problem comes whenever I set "==" instead of ", or >" , there's not any result, when I've previously checked that actually there are a lot of results with that condition...so when I use < or > no problem, but if I use == I got NONE results....
how is this possible?
How could I fix it?
Thanks in advance
Leave a comment:
-
A very simple question for programmers
I apologize for my programming ignorance but I'm stuck in something that it shouldn't happen
I'm testing a very simple condition:
if ( (Close[0]-(Close[0]+Open[0])/2) < -0.000175)
{
EnterShort(100000, "SELL");
}
I work with Range bars, onBarUpdate=true....ect etc
The problem comes whenever I set "==" instead of ", or >" , there's not any result, when I've previously checked that actually there are a lot of results with that condition...so when I use < or > no problem, but if I use == I got NONE results....
how is this possible?
How could I fix it?
Thanks in advanceTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by JGriff5646, Today, 10:02 PM
|
0 responses
9 views
0 likes
|
Last Post
by JGriff5646
Today, 10:02 PM
|
||
Started by AdamDJ8, Today, 09:18 PM
|
0 responses
5 views
0 likes
|
Last Post
by AdamDJ8
Today, 09:18 PM
|
||
Started by knowmad, Today, 03:52 AM
|
2 responses
33 views
0 likes
|
Last Post
by knowmad
Today, 09:03 PM
|
||
Started by ETFVoyageur, Today, 07:05 PM
|
0 responses
11 views
0 likes
|
Last Post
by ETFVoyageur
Today, 07:05 PM
|
||
Started by Orion815, 05-02-2024, 08:39 AM
|
2 responses
18 views
0 likes
|
Last Post
by Orion815
Today, 06:24 PM
|
Leave a comment: