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
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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! =)