- ago
If I compare the HistoryScale of two BarsHistory (both Daily) by using Scale1.CompareTo(Scale2) I get -1. Shouldn't it return 0 ? When I use == operater, it returns true, as expected?
0
731
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.17% )
- ago
#1
No, if you want to test Equality, use Equals.

CompareTo is used to determine if the scale is greater (higher) than the one "on the right". If it's not greater, then CompareTo returns -1, otherwise 1 if it's greater.

Example:
HistoryScale.Daily.CompareTo(HistoryScale.Minute30) will return 1, because Daily is a higher scale than 30 minute bars.
0
- ago
#2
ok, thanks (I assumed IComparable documentation on docs.microsoft.com)!
0
Cone8
 ( 6.17% )
- ago
#3
Hmm, good point. Unless Glitch implemented it that way specifically, we could change it to return 0 for equality. Glitch?
0
Glitch8
 ( 12.53% )
- ago
#4
I made it return zero if equal for Build 6.
1
Best Answer

Reply

Bookmark

Sort