MQL4 Learning - page 125

 

Hi,

I have a doubt.

If i use cycle for if into the code i put an icustom with different timeframe. It is calculate correctly?

Example

I attach the ea in h1 and call in the code this loop. It give me the right result? Or it check (i) for the bars in the current timeFrame?

for(int i = 0 ; i < 1500 ; i++)

{

temp = iCustom(NULL,240,"Zigzag",.....,i);

if (temp != 0) count = count+1;

if(count == 1 && temp != 0) {p4 = temp;}

if(count == 2 && temp != 0) {p3 = temp;}

if(count == 3 && temp != 0) {p2 = temp;}

if(count == 4 && temp != 0) {p1 = temp;}

if(count == 5) break;

}
 

If you want to check the 4 hour time frame (and it seems that you do) then it is OK regardless of what is the current chart time frame

dasio:
Hi,

I have a doubt.

If i use cycle for if into the code i put an icustom with different timeframe. It is calculate correctly?

Example

I attach the ea in h1 and call in the code this loop. It give me the right result? Or it check (i) for the bars in the current timeFrame?

for(int i = 0 ; i < 1500 ; i++)

{

temp = iCustom(NULL,240,"Zigzag",.....,i);

if (temp != 0) count = count+1;

if(count == 1 && temp != 0) {p4 = temp;}

if(count == 2 && temp != 0) {p3 = temp;}

if(count == 3 && temp != 0) {p2 = temp;}

if(count == 4 && temp != 0) {p1 = temp;}

if(count == 5) break;

}
 

Where is the mistake

In an EA, I wrote "double Top=High;" to obtain the highest Close, but I obtain the highest High.

What is necessary to change to obtain the highest Close ?

Thank you in advance.

 

change it to this :

double Top=Close;
Jovager:
In an EA, I wrote "double Top=High;" to obtain the highest Close, but I obtain the highest High.

What is necessary to change to obtain the highest Close ?

Thank you in advance.
 

How do I get an EA to place a trade based on the colour change of an indicator?

Hi everyone,

I have only just started delving into MetaTrader and would like to know how to get an EA to place a trade based on the colour change of an indicator?

e.g. Moving average that changes colour and place a trade based on when it changes colour. If it's going up and it's green, when it changes to red, how do I get it to place the trade when it goes red?

Looking forward to hearing from you.

Waisalima

 

waisalima

You would have to read the values of the average and then check if there is a change in slope direction (you can not trade on the direction alone because that way you would have a lot of trades, but you have to trade on slope direction change) There are several ways to do it but they depend on what indicator you would use, so this answer is as general as it can get, for more specific solution the average you are using (built in or custom) should be known

waisalima:
Hi everyone,

I have only just started delving into MetaTrader and would like to know how to get an EA to place a trade based on the colour change of an indicator?

e.g. Moving average that changes colour and place a trade based on when it changes colour. If it's going up and it's green, when it changes to red, how do I get it to place the trade when it goes red?

Looking forward to hearing from you.

Waisalima
 

Hi, can I get the OpenTime and the CloseTime from the current Symbol? I mean not the expiration, the daily times.

I don't think there is a possibility with MarketInfo(..).

But I also can't say, when there is no difference between the minutes, so there is no trading time.

 

sunshineh

You can not get the starting and ending time but you can get if the trading for a specified symbol is allowed at all (which is almost exactly what you want : outside the start and end time the MarketInfo(Symbol(),MODE_TRADEALLOWED) will return false)

sunshineh:
Hi, can I get the OpenTime and the CloseTime from the current Symbol? I mean not the expiration, the daily times.

I don't think there is a possibility with MarketInfo(..).

But I also can't say, when there is no difference between the minutes, so there is no trading time.
 

Hi mladen;

I wanna use dynamic grid size instead of fix value , would you mind take a look my code stated as below and give me a feedback ,is it correct definition or not?

thanks in advance

//+-----------------------------------------------------------------+

int Calculagridsize()

{ double GridSet;

double atrvalue=iATR(NULL,PERIOD_D1,14,0); ;

if(Digits<4)GridSet=atrvalue*100;

else GridSet=atrvalue*10000;

grid_size=GridSet;

}

//+-----------------------------------------------------------------+

 

kemal44

It should be OK

kemal44:
Hi mladen;

I wanna use dynamic grid size instead of fix value , would you mind take a look my code stated as below and give me a feedback ,is it correct definition or not?

thanks in advance

//+-----------------------------------------------------------------+

int Calculagridsize()

{ double GridSet;

double atrvalue=iATR(NULL,PERIOD_D1,14,0); ;

if(Digits<4)GridSet=atrvalue*100;

else GridSet=atrvalue*10000;

grid_size=GridSet;

}

//+-----------------------------------------------------------------+