EA for Previous BAR Close, High, Low, Open

 

Hi Guys,

How can I make an Ea which lok for the previous BAR open, close, high and low price and then depending on the conditions take long position or short...

Thanks

Babar

 

Can someone please give me an idea...???

Thanks

Babar

 

Hi,

I'm not strong in MT4 coding but I think you have to use this:

Open => Previous open bar value.

Close => Previous close bar value.

High => Previous high bar value.

Low => Previous low bar value.

bye bye

 
babarmughal:
Hi Guys,

How can I make an Ea which lok for the previous BAR open, close, high and low price and then depending on the conditions take long position or short...

Thanks

Babar

You can define some variables:

double PreviousClose=iClose(Symbol(),NULL,1);

double CurrentClose=iClose(Symbol(),NULL,0);

double PreviousOpen=iOpen(Symbol(),NULL,1);

double CurrentOpen=iOpen(Symbol(),NULL,0);

double PreviousHigh=iHigh(Symbol(),NULL,1);

double CurrentHigh=iHigh(Symbol(),NULL,0);

double PreviousLow=iLow(Symbol(),NULL,1);

double CurrentLow=iLow(Symbol(),NULL,0);

I hope this helps.

Bye.

 
cucurucu:
You can define some variables:
double PreviousClose=iClose(Symbol(),NULL,1);

double CurrentClose=iClose(Symbol(),NULL,0);

double PreviousOpen=iOpen(Symbol(),NULL,1);

double CurrentOpen=iOpen(Symbol(),NULL,0);

double PreviousHigh=iHigh(Symbol(),NULL,1);

double CurrentHigh=iHigh(Symbol(),NULL,0);

double PreviousLow=iLow(Symbol(),NULL,1);

double CurrentLow=iLow(Symbol(),NULL,0);

I hope this helps.

Bye.

HI cucurucu,

Thanks for your help...can you please tell me how can I define the current price.....is it something like ASK or BID ????

Thanks

 

It is Ask and Bid... babarmughal look: there is that saying - RTFM that is the short form of Read The Fucking Manual... Before you ask a question try to find some info in MT4 help files ... it will help you much more and you will find some extra info.

Best Regards

P7

 
babarmughal:
HI cucurucu,

Thanks for your help...can you please tell me how can I define the current price.....is it something like ASK or BID ????

Thanks

You can use Ask[] or Bid[], but I preffer using the current close.

double CurrentClose=iClose(Symbol(),NULL,0);

This is the current price, because the bar is not closed, and the CurrentClose is moving. So, let's say that you want the expert to act if the current price is higher than the previous close and the current open is higher than the previous open... you have to code it like this:

if ((CurrentClose>PreviousClose) && (CurrentOpen>PreviousOpen)) {......}

Bye.

Reason: