- 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
560
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 24.57% )
- 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
 ( 24.57% )
- ago
#3
Hmm, good point. Unless Glitch implemented it that way specifically, we could change it to return 0 for equality. Glitch?
0
Glitch8
 ( 10.41% )
- ago
#4
I made it return zero if equal for Build 6.
1
Best Answer

Reply

Bookmark

Sort