thanx
many thanx
but i didn't find an ea that uses somthing cross of 2 moving average works in all time frames ,, thanx
any help?
hi
could any one please convert this simple expert advisor cross over to ,, smoothed one
many thanx
//+------------------------------------------------------------------+
//| Rossman1.mq4 |
//| Rossman |
//| |
//+------------------------------------------------------------------+
#property copyright "Rossman"
//declare external variables to be used in start function
extern int MAperiodSlow=10;
extern int MAperiodFast=5;
extern int stopLoss=150;
extern int takeProfit=300;
extern double lots=1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
//declare local variables to be used below
//total is used to make sure no order is placed if an order is open
//cnt stands for count and is used in the for loop that closes open orders
int total, cnt;
//maSlow and maFast are the 2 moving averages for the current bar in this EA
//maSlowPrevious and maFastPrevious are are the 2 moving averages for the
//previous bar. They are used to determine if the slow and fast moving averages have crossed
double maSlow,maSlowPrevious,maFast,maFastPrevious;
//I use simple moving average and the close price to calculate the moving average
maSlow = iMA(NULL,0,MAperiodSlow,0,MODE_SMA,PRICE_CLOSE,0);
maSlowPrevious = iMA(NULL,0,MAperiodSlow,0,MODE_SMA,PRICE_CLOSE,1);
maFast = iMA(NULL,0,MAperiodFast,0,MODE_SMA,PRICE_CLOSE,0);
maFastPrevious = iMA(NULL,0,MAperiodFast,0,MODE_SMA,PRICE_CLOSE,1);
//OrdersTotal() returns the number of open orders
total=OrdersTotal();
//for loop counts through the open orders. Order 1 is labeled 0 so we start with
//cnt=0 and end with cnt<total not cnt<=total and we count up through the orders with cnt++
for(cnt=0;cnt<total;cnt++)
{
//select the order from open trades by the position which is the value of cnt
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
//if the order is a buy order (ie long position)
if(OrderType() == OP_BUY)
{
//and if the fast moving average is less than the slow moving average
if(maFast<maSlow)
{
//close the selected order
OrderClose(OrderTicket(),OrderLots(),Bid,3,DarkGreen);
return(0);
}
}
//if not buy order, then it is a sell order (ie short position)
else
{
//and if the fast moving average is greater than the slow moving average
if(maFast>maSlow)
{
//close the selected order
OrderClose(OrderTicket(),OrderLots(),Ask,3,Maroon);
return(0);
}
}
return(0);
}
//if the total number of open orders is less than one (ie there aren't any)
if(total<1)
{
//and if the fast moving average is greater than the slow moving average and the fast moving average was less than
//the slow moving average one unit of time ago (this means the fast moving average has crossed up through the slow moving average)
if(maFast>maSlow && maFastPrevious<maSlowPrevious)
{
//make a buy order at the ask price for the number of lots in the external variable 'lots' with a stoploss equal to
//the external variable 'stopLoss' and a limit equal to the external variable 'take profit'
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask-stopLoss*Point,Ask+takeProfit*Point,"Rossman1-buy",12055,0,Lime);
return(0);
}
//or if the fast moving average is less than the slow moving average and the fast moving average was greater than
//the slow moving average one unit of time ago (this means the fast moving average has crossed down through the slow moving average)
if(maFastmaSlowPrevious)
{
//make a sell order at the bid price for the number of lots in the external variable 'lots' with a stoploss equal to
//the external variable 'stopLoss' and a limit equal to the external variable 'take profit'
OrderSend(Symbol(),OP_SELL,lots,Bid,3,Bid+stopLoss*Point,Bid-takeProfit*Point,"Rossman1-sell",12055,0,Red);
return(0);
}
return(0);
}
//----
return(0);
}
//+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
please i need
smooth moving avarage crossover expert advisor
many thanx