Adding Lower TF NON-NB Trading to Baluda's MultiBob

Post Reply
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Adding Lower TF NON-NB Trading to Baluda's MultiBob

Post by gaheitman »

dancingphil wrote:The compile errors I got from the previous post were not unexpected. Up until here I had done nothing about declaring or defining any of my M5 and M15 variables.

I have created many extern whatever-type-inputs over the years, but I have never defined anything before. But this project quickly caused me to have to so far create the following that are marked in red:
#define VALUESCOUNT 59
#define iM15Slope 60
#define iM5Slope 61
#define iM15SlopeTrend 62
#define iM5SlopeTrend 63
#define iM15SlopeAngle 64
#define iM15PrevSlope 65
#define iM5SlopeAngle 66
#define iM5PrevSlope 67
#define iM15Woh 68
#define iM15WohSlope 69
#define iM15WohAngle 70
#define iM15WohTrend 71
#define iM5Woh 72
#define iM5WohSlope 73
#define iM5WohAngle 74
#define iM5WohTrend 75
#define M15TMACross 76
#define M5TMACross 77
#define M15PrevSlope 78
#define M5PrevSlope 79
#define M15Slope 80
#define M5Slope 81
Don't forget to update VALUESCOUNT to cover your new data values. It determines the size of the array used to store the values for all the currencies. It needs to be 82 now, unless you've added more items.

Actually, you've left a "hole" at value 59. Your added indexes should start at 60 and VALUESCOUNT would then be one more than the highest index you add (so really it would be 81).

George
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: Adding Lower TF NON-NB Trading to Baluda's MultiBob

Post by NeoTrader »

Hi dancingphil,

The #define is used in most cases to declare constant names with constant numeric values so you don't have to juggle (and remember) the different numeric values...
eg.
#define up 0 // "Up. "
#define down 1 // "Down. "
#define none 2 // "None. "

It is easier to remember the constant names "up", "down" and "none" instead the represented numeric values 0, 1 and 2.
if you now use the constant "up" in your code it is automatically replaced by it's value (in this case 0)

hope that this helps a little bit,

happy weekend,

NeoTrader

-
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Adding Lower TF NON-NB Trading to Baluda's MultiBob

Post by gaheitman »

dancingphil wrote:Ah, OK; so there is no rationale behind which ones are all defined by the same number?

Phil
The numbers just need to be different within a group of items you are comparing. For example, if you defined different fruits like this:

//apples
#define red_delicious 0
#define granny_smith 1
#define fuij 2

//oranges
#define navel 0
#define blood 1
#define valencia 2

We can now test to see whether apple == fuji. The numbers within each group do not matter, as long as they are different. We know if isn't an orange, because our code doesn't need to differentiate between apples and oranges, it always knows which kind we have.

Now, if your code doesn't know that it has an apple, you would need to number them sequentially so that you could test to see what you had.

//apples
#define red_delicious 0
#define granny_smith 1
#define fuji 2

//oranges
#define navel 3
#define blood 4
#define valencia 5

Now, if fruit >= 3, we know it is an orange.

These numbers are arbitrary, the numbers for the indexes need to be sequential, since they are used to identify a position within an array. The names are used for readability.

George
Post Reply

Return to “Coders Hangout”