I am in the process of reading a book about mql and I have just created my first expert advisor. The EA buys when the opening price of the candle before is below the 100 sma and the closing price above. I use the count variable to limit the number of trades to one but I would like the EA to continue to trade after the trade has been closed. How do I do that?
QuoteDisliked//+------------------------------------------------------------------+
//| Gamblersgrid.mq4 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
double stop_loss;
double take_profit;
int count;
double lots=0.01;
int start()
{
//----
if (count <= 0 && Close[1] > iMA(NULL,0,100,0,0,0,1) && Open[1] < iMA(NULL,0,100,0,0,0,1))
{
stop_loss=Open[1];
take_profit=Close[1]+(Close[1]-Open[1])*4;
OrderSend(Symbol(),OP_BUY,lots,Ask,10,stop_loss,take_profit);
count++;
}
//----
return(0);
}
//+------------------------------------------------------------------+
If slaughterhouses had glass walls, everyone would be a vegetarian!