Coding help - page 388

 
mladen:
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?

 
madopter:
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

 
mladen:
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

 
madopter:
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?

 

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

double h1adx = iADX(NULL,PERIOD_H1,2,);

//h4 data

double h4adx = iADX(NULL,PERIOD_H4,2);

//d1 data

double d1adx = iADX(NULL,PERIOD_D1,2);

The three line of coding above are tagged as :

')' - syntax error, parameter missed

Could some kind soul put them right for me?

 
mladen:
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.

 
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

double h1adx = iADX(NULL,PERIOD_H1,2,);

//h4 data

double h4adx = iADX(NULL,PERIOD_H4,2);

//d1 data

double d1adx = iADX(NULL,PERIOD_D1,2);

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) :

double h4adx = iADX(NULL,PERIOD_H4,adxPeriod,adxPrice,MODE_MAIN,2);

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

 

Many, many thanks. Appreciate the help.

 

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:
 

Hi,

I am always having problems with writing text objects over the bars in my chart.

For example

ObjectCreate ("Xh", OBJ_TEXT,0,Time[0],High[0]+1*pips2dbl);

ObjectSetText("Xh","1",10,"Tahoma",Orange);

ObjectCreate ("X", OBJ_TEXT,0,Time[0],Low[0]-1*pips2dbl);

ObjectSetText("Xl","1",10,"Tahoma",Orange);

This is working fine with text objects below my bars because my font object is fixed "on the head of" my text.

But if I want to write some text above the bar, I don't now how my pips my text in font size 10 is an so it is written into the bars.

There is also a problem when I write my text in bigger timeframes f.e. "H1", "D1" oder "W1" because there I had to change my font-distance to the high- or low-value, too.

I know I can rotate my text to 90° but I don't want to do that.

So do you know a solution for that problem?

Reason: