Need help with a code pls!

 

Hi all,

 I've been trying to write 2 separate codes that simply do the following:

 The first code:

* checks particularly whether a new PERIOD_H4 bar is formed with an alert, with the option to change it to any other timeframes if needed. 

  The second code:

1- places a pending sell order if: current bid < (high + low) / 2 of previous PERIOD_H4 bar.

 2- places a pending buy order if: current ask > (high + low) / 2 of previous PERIOD_H4 bar.

appreciate if you can help me with these two codes.

thanks a million in advance.

 

Regards,

MJ Leroy 

 
mady_leroy:

Hi all,

 I've been trying to write 2 separate codes that simply do the following:

 The first code:

* checks particularly whether a new PERIOD_H4 bar is formed with an alert, with the option to change it to any other timeframes if needed. 

  The second code:

1- places a pending sell order if: current bid < (high + low) / 2 of previous PERIOD_H4 bar.

 2- places a pending buy order if: current ask > (high + low) / 2 of previous PERIOD_H4 bar.

appreciate if you can help me with these two codes.

thanks a million in advance.

Regards,

MJ Leroy 

And where is your code ?, why don't you show it ?.

Use Timeseries access.

 

Actually am new in coding, and am trying to make that code using a software called Forex EA Generator 4, with no luck.

Unfortunately it's hard for me at the moment to code using what you mentioned, but I have just finished reading an intro about coding in mql.

and wish if you can help me write these codes :)

 

 

For the first code I wrote the following:

 

datetime New_Time_H4;
bool New_Bar_H4;

int start()  
 {

if(New_Time_H4!= iTime(NULL,PERIOD_H4,0))
 {
New_Time_H4=iTime(NULL,PERIOD_H4,0); // New time set
New_Bar_H4=true; // A new bar detected
Alert("New Bar H4", "formed");

}

}
 
mady_leroy:

Actually am new in coding, and am trying to make that code using a software called Forex EA Generator 4, with no luck.

That's a bad idea,  these EA builders usually generate bad code that you then have no idea of how to fix . . .  if you want to code you need to learn,  for examples of bad EA Builder code:  https://www.mql5.com/en/forum/139865
 

RaptorUK:
That's a bad idea,  these EA builders usually generate bad code that you then have no idea of how to fix . . .  if you want to code you need to learn,  for examples of bad EA Builder code:  https://www.mql5.com/en/forum/139865

I know, but it helps me get some idea and sense of coding again, knowing that I never wrote a program since high school, BASIC was the language, I believe :)