Download MetaTrader 5
To add comments, please log in or register
Have you just installed MetaTrader 5? Learn it in details!
Bradford Hall
183
Bradford Hall 2016.05.23 05:07 

Hey everyone, I'm new to MQL4 programming and was wondering how I would code this in MQL4


if  Previous Bar Closes BELOW (less than?)

{
Simple Moving Average (1) Shift (5) - 0.0020

}

, Close LONG position at Market price.

If Previous Bar Closes  ABOVE (greater than?)

{
Simple Moving Average (1) Shift (5) + 0.0020

}

Close SHORT position at Market Price




If anybody has resources to point me to or can be generous enough if this is extremely simple for them to write, I would be very grateful.

 I will gladly pay  someone some beer money and share my expert if there are any other newbies out there like myself.

Thanks! =)

Mohamed Hamdy
1005
Mohamed Hamdy 2016.05.23 06:52  
Bradford Hall:

Hey everyone, I'm new to MQL4 programming and was wondering how I would code this in MQL4


if  Previous Bar Closes BELOW (less than?)

{
Simple Moving Average (1) Shift (5) - 0.0020

}

, Close LONG position at Market price.

If Previous Bar Closes  ABOVE (greater than?)

{
Simple Moving Average (1) Shift (5) + 0.0020

}

Close SHORT position at Market Price




If anybody has resources to point me to or can be generous enough if this is extremely simple for them to write, I would be very grateful.

 I will gladly pay  someone some beer money and share my expert if there are any other newbies out there like myself.

Thanks! =)

if(Close[1]<iMA(Symbol(),0,1,5,MODE_SMA,PRICE_CLOSE,1))

 {

     if(OrderSelect(OrderTicket,SELECT_BY_TICKET,MODE_TRADES))

         OrderClose(OrderTicket(),OrderLots(),Bid,3,clrRed);

}

and do the opposite for the SHORT closing

also see the documentation about OrderSelect() and OrderClose() functions

/
To add comments, please log in or register