Quote:
Originally Posted by FerruFx
Please post also the code lines with your iCustom() function
FerruFx
|
Yeah thanks for offering to help, i have fixed the problem already, it was a problem with my indicator.
However i noticed that my EA doesn't trade according to the Buy or Sell Arrows, here's my EA code.
Thanks in advance for your prompt reply,
//+------------------------------------------------------------------+
//| Anubis.mq4 |
//| Copyright © 2008, Sola Ajayi, NerdyMonk |
//|
shollylabor@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Sola Ajayi, NerdyMonk"
#property link "shollylabor@gmail.com"
extern double TakeProfit = 500;
extern double Lots = 1;
extern double TrailingStop = 200;
double SS_SELL_0=0, SS_BUY_0=0;
bool SSIsBuy=false, SSIsSell=false;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int cnt,ticket,total;
SS_SELL_0 = iCustom(Symbol(),Period(),"zeus",4,0,0);
SS_BUY_0 = iCustom(Symbol(),Period(),"zeus",4,1,0);
if (SS_SELL_0 > 0) {SSIsSell=true;SSIsBuy=false;}
if (SS_BUY_0 > 0) {SSIsSell=false;SSIsBuy=true;}
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if(SSIsBuy == true)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point,"zeus",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(SSIsSell == true)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"zeus",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
// it is important to enter the market correctly,
// but it is more important to exit it correctly...
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(SSIsSell == true)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else // go to short position
{
// should it be closed?
if(SSIsBuy == true)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ; // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+