# Coding help - page 388

83391

Dear coders, is there an easy way to increase the lot size based on balance? For example, let's say I want to trade lot 1 for every 10000 units of balance, or if I want to do 0.02 for every 1000 units of balance? Which parameters would I need and what would be the code?

In the first example, I would be in lot 1 for 10000 <= balance <= 19000, and lot 2 for 20000 <= balance <= 29000, etc.

Thank you.

You can do that like this

double lots=5; // or whatever maximal lot size you chose

while (true)

{

if (AccountBalance()<19000) { lots = 1; break; }

if (AccountBalance()<29000) { lots = 2; break; }

if (AccountBalance()<39000) { lots = 3; break; }

//

//

// futher comparisons here in ascending order

//

//

break;

}

161

You can do that like this
double lots=5; // or whatever maximal lot size you chose

while (true)

{

if (AccountBalance()<19000) { lots = 1; break; }

if (AccountBalance()<29000) { lots = 2; break; }

if (AccountBalance()<39000) { lots = 3; break; }

//

//

// futher comparisons here in ascending order

//

//

break;

}

Thank you mladen, this would do the job. Do you think one can construct an algebraic expression so that the amounts aren't hardcoded? I think it might be doable with two parameters?

83391

Thank you mladen, this would do the job. Do you think one can construct an algebraic expression so that the amounts aren't hardcoded? I think it might be doable with two parameters?

Yes, why not ...

That would make it flexible to use

161

Yes, why not ... That would make it flexible to use

I can't figure out how to do it but I haven't spent a ton of time trying to figure it out. If it's obvious to you, please let me know

83391

I can't figure out how to do it but I haven't spent a ton of time trying to figure it out. If it's obvious to you, please let me know

What parts of that code would you like to be adjustable?

242

Hi. I'm trying to alter the 3 Ducks indicator from using moving averages, to using the ADX indicator. With an input value of '2'. All is well until I compile my efforts....then this is what I Get in the 'Description box!

//h1 data

//h4 data

//d1 data

The three line of coding above are tagged as :

')' - syntax error, parameter missed

Could some kind soul put them right for me?

161

What parts of that code would you like to be adjustable?

The adjustable parts should be the lot size, and the account balance to which the lot is applied to. For example, the parameters might be A = 0.01, B = \$5000, or, A = 1.00, B = \$10000.

83391

Jeeves:
Hi. I'm trying to alter the 3 Ducks indicator from using moving averages, to using the ADX indicator. With an input value of '2'. All is well until I compile my efforts....then this is what I Get in the 'Description box!

//h1 data

//h4 data

//d1 data

The three line of coding above are tagged as :

')' - syntax error, parameter missed

Could some kind soul put them right for me?

Jeeves

You are missing parameters for iADX() call. One example would be this (to get the value of the ADX itself) :

If you want to get the value of +DI replace the MODE_MAIN with MODE_PLUSDI, and in the case of -DI replace that with MODE_MINUSDI

Also, replace adxPeriod and adxPrice with desired values

242

Many, many thanks. Appreciate the help.

40

Template runs slowly

I have found nice scalping system and template but it runs so slowly after installing this system. Maybe someone is able to look it and detect what could cause it.

Template and indicators:

1m_alf_scalp.zip

Files: