How to code? - page 99

 

Thanks Ferru, this is what I needed!

You are great!

 

translate this metastock-function

hi,

can you code this function in mql from metastock-language ?

ThroughtBars(1,MACD(),29)

thanks in advance

giapel

 

I use trend envelope but during up movement the buffer about trendenvelope short write 254564115 strange number so i use a simple code to put it at zero, there is another way withouth force it to 0?

TrendEnvUp = iCustom(NULL,0,IndicatorName4,2,0,0,0,0,0,0,0); // trendenvelopes

TrendEnvDown = iCustom(NULL,0,IndicatorName4,2,0,0,0,0,0,1,0); // trendenvelopes

if (TrendEnvUp > 10)

TrendEnvUp=0;

if (TrendEnvDown > 10)

TrendEnvDown=0;
 

I have another simple questio, that I can't solve.

I would like to open multiposition for every signal that I receive. Exactly I would like to open 3 position for every signal, what's the code to do this.

Regards

 

problem with

hi

in my EA , I try to print my two variables but it's not working:

**********************************************************

double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

double m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

for(int i=1; i<500 ; i--)

{

m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + i);

m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + i);

Print(m_10+ " " + m_20);

}

**********************************************************

this is the message error :

'[' assignment expected

Help please!!

Thanks in advance.

 

something wrong in this line... for(int i=1; i<500 ; i--)

try with i++

for(int i=1; i<500 ; i++)

natsirte:
hi

in my EA , I try to print my two variables but it's not working:

**********************************************************

double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

double m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

for(int i=1; i<500 ; i--)

{

m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + i);

m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + i);

Print(m_10+ " " + m_20);

}

**********************************************************

this is the message error :

'[' assignment expected

Help please!!

Thanks in advance.
 
natsirte:
hi

in my EA , I try to print my two variables but it's not working:

**********************************************************

double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

double m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

for(int i=1; i<500 ; i--)

{

m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + i);

m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + i);

Print(m_10+ " " + m_20);

}

**********************************************************

this is the message error :

'[' assignment expected

Help please!!

Thanks in advance.

Did you declared the buffers?

double m_10[];

double m_20[];

FerruFx

 

This will do it.

If it's only for the print function, no arrays needed.

If you need it for drawing lines, you need something else to activate the buffers.

and the for() function needs to count up, not down.

************************************************** ********

int Current;

double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

double m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + 0);

for(int i=1; i<500 ; i++){

m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + i);

m_20 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, Current + i);

Print(m_10+ " " + m_20);

}

************************************************** ********

FerruFx:
Did you declared the buffers?

double m_10[];

double m_20[];

FerruFx
 
mauro269:
I have another simple questio, that I can't solve.

I would like to open multiposition for every signal that I receive. Exactly I would like to open 3 position for every signal, what's the code to do this.

Regards

Just use 3 OrderSend calls instead of 1.

Robert

 

Variable problem

Hi,

I am currenty programming an expert which does calculations based on the OHLC of the previous bar.

My problem is this:

I have a variable called "var5".

For the first bar that is counted, var5 is the open of that bar.

For every subsequent bar, var5 is the value of var5 on the previous bar, divided by 2.

I have no idea how to code this into MQL, and was wondering if anyone could show me an example of how this might be done?

Thanks in advance for any replies.

Reason: