can some one help me Fine tune a EA please
it can do better - all i see it buy and sell in the wrong places
Do you want to explain your strategy? We need to check if it is coded according to the stated strategy before we can finetune it.
If the codes are correct and we are getting poor trades from the EA, then the strategy is at fault? Is the strategy working well from manual trading?
Do you want to explain your strategy? We need to check if it is coded according to the stated strategy before we can finetune it.
If the codes are correct and we are getting poor trades from the EA, then the strategy is at fault? Is the strategy working well from manual trading?
thank you for comeing back
the strategy is - it must only buy or sell when ema cross. there is a setting that works well and if it only buy and sell on the crosses it will take profit
i have tied it as it is but it does not buy on the cross of the 2 ema's
it must close open order and buy when short ema cross the long ema and the other way round. at this stage i want it only to do that.
then we can do the 2nd stage. no money management at this stage. i am new to programing but want to learn more
can u help me
as it is it do the job on the eur/usd 15 and1h tf - but not enough
thank you for comeing back
the strategy is - it must only buy or sell when ema cross. there is a setting that works well and if it only buy and sell on the crosses it will take profit
i have tied it as it is but it does not buy on the cross of the 2 ema's
it must close open order and buy when short ema cross the long ema and the other way round. at this stage i want it only to do that.
then we can do the 2nd stage. no money management at this stage. i am new to programing but want to learn more
can u help me
as it is it do the job on the eur/usd 15 and1h tf - but not enough
i suspect so; for EMA crosses your code is incorrect
Ema=iMA(NULL,0,ShortEma,LongEma,MODE_EMA,PRICE_CLOSE,0);
you need two iMA each for the longema and shortema
SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
and to check for cross
if (SEMA1>LEMA1 && SEMA2<LEMA2) send buy order
and for sell
if (SEMA1<LEMA1 && SEMA2>LEMA2) send sell order
i suspect so; for EMA crosses your code is incorrect
Ema=iMA(NULL,0,ShortEma,LongEma,MODE_EMA,PRICE_CLOSE,0);
you need two iMA each for the longema and shortema
SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
and to check for cross
if (SEMA1>LEMA1 && SEMA2<LEMA2) send buy order
and for sell
if (SEMA1<LEMA1 && SEMA2>LEMA2) send sell order
ok so the
SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
must be placed in the "check for open orders conditions - below "get moving average"
and the "
if (SEMA1>LEMA1 && SEMA2<LEMA2) send buy order" where ?
also the LEMA1 AND LEMA2 must I defined at the top
still new in this
my skype is delcor59 if you want to skype me
thanks for your help
ok so the
SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
must be placed in the "check for open orders conditions - below "get moving average"
and the "
if (SEMA1>LEMA1 && SEMA2<LEMA2) send buy order" where ?
also the LEMA1 AND LEMA2 must I defined at the top
still new in this
my skype is delcor59 if you want to skype me
thanks for your help
something like this modifying fr yr own codes....
void CheckForOpen()
{
double Ema;
int res;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
Ema=iMA(NULL,0,ShortEma,LongEma,MODE_EMA,PRICE_CLOSE,0);
double SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
double LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
double SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
double LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
//---- sell conditions
// if(Open[1]>Ema && Close[1]<Ema)
if (SEMA1<LEMA1 && SEMA2>LEMA2)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
return;
}
//---- buy conditions
// if(Open[1]<Ema && Close[1]>Ema)
if (SEMA1>LEMA1 && SEMA2<LEMA2)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);
return;
}
//----
}
void CheckForClose()
{
double Ema;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
Ema=iMA(NULL,0,ShortEma,LongEma,MODE_EMA,PRICE_CLOSE,0);
double SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
double LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
double SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
double LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
// if(Open[1]>Ema && Close[1]<Ema)
if (SEMA1<LEMA1 && SEMA2>LEMA2) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
// if(Open[1]<Ema && Close[1]>Ema)
if (SEMA1>LEMA1 && SEMA2<LEMA2) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
//----
}
something like this modifying fr yr own codes....
void CheckForOpen()
{
double Ema;
int res;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
Ema=iMA(NULL,0,ShortEma,LongEma,MODE_EMA,PRICE_CLOSE,0);
double SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
double LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
double SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
double LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
//---- sell conditions
// if(Open[1]>Ema && Close[1]<Ema)
if (SEMA1<LEMA1 && SEMA2>LEMA2)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
return;
}
//---- buy conditions
// if(Open[1]<Ema && Close[1]>Ema)
if (SEMA1>LEMA1 && SEMA2<LEMA2)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);
return;
}
//----
}
void CheckForClose()
{
double Ema;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
Ema=iMA(NULL,0,ShortEma,LongEma,MODE_EMA,PRICE_CLOSE,0);
double SEMA1=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1);
double LEMA1=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);
double SEMA2=iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2);
double LEMA2=iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,2);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
// if(Open[1]>Ema && Close[1]<Ema)
if (SEMA1<LEMA1 && SEMA2>LEMA2) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
// if(Open[1]<Ema && Close[1]>Ema)
if (SEMA1>LEMA1 && SEMA2<LEMA2) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
//----
}
thank you again
some thing is not right. when i back test the Ea it show only buys and no sells
thank you again
some thing is not right. when i back test the Ea it show only buys and no sells
noticed that depending on which order is fired first ie buy or sell, once the cross starts you fire an order and when the opposite cross you close the order; in yr start() when u check for existence of market order, u will prevent the one of the order type never to fire ie when u start with buy it will always be buy; when u start with a sell order, it will always be a sell order; take out that check condition
noticed that depending on which order is fired first ie buy or sell, once the cross starts you fire an order and when the opposite cross you close the order; in yr start() when u check for existence of market order, u will prevent the one of the order type never to fire ie when u start with buy it will always be buy; when u start with a sell order, it will always be a sell order; take out that check condition
are your refering to the check condition at the bottom of the EA
//+------------------------------------------------------------------+//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
because there is also
void CheckForOpen()
void CheckForClose()
are your refering to the check condition at the bottom of the EA
//+------------------------------------------------------------------+//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
because there is also
void CheckForOpen()
void CheckForClose()
tell me is there a test system on the EA programing to show you step for step what happens when this EA runs
are your refering to the check condition at the bottom of the EA
//+------------------------------------------------------------------+//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
because there is also
void CheckForOpen()
void CheckForClose()
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
CheckForOpen();
CheckForClose();
//----
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
can some one help me Fine tune a EA please
it can do better - all i see it buy and sell in the wrong places