//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double SFCSRed=iCustom(NULL,0,"SFCS5",1,0);
double SFCSGreen=iCustom(NULL,0,"SFCS5",2,0);
//--- Buy = 1 && Sell = -1 ---//
double SFCC=iCustom(NULL,0,"SFCC5",5,0);
double high_1=iHigh(NULL,0,1);
double low_1=iLow(NULL,0,1);
double ma5_E_HLCC_TF15=iMA(NULL,15,5,0,MODE_EMA,PRICE_WEIGHTED,0);
double ma15_E_HLCC_TF15=iMA(NULL,15,15,0,MODE_EMA,PRICE_WEIGHTED,0);
double ma1_S_C_TF15=iMA(NULL,15,1,0,MODE_SMA,PRICE_CLOSE,0);
double WPR_TF15=iWPR(NULL,15,14,0);
double RSI_TF15=iRSI(NULL,15,14,PRICE_CLOSE,0);
double ma13_TF15 = iMA(NULL, 15, 13, 0, MODE_SMA, PRICE_CLOSE,0);
double ma26_TF15 = iMA(NULL, 15, 26, 0, MODE_SMA, PRICE_CLOSE,0);
double ma223_TF15 = iMA(NULL, 15, 233, 0, MODE_SMA, PRICE_CLOSE,0);
double ma26_TF15_1 = iMA(NULL, 15, 26, 0, MODE_SMA, PRICE_CLOSE,1);
int total;
int ticket;
total=OrdersTotal();
if(total<1){
if(SFCC == 1 && SFCSGreen !=2147483647){
OrderClose(OrderTicket(),0.1,Bid,3,Red);
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-Point*StopLoss,Ask+Point*TakeProfit,"firstea",magic,0,Blue);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
}
if(SFCC == -1 && SFCSRed !=2147483647){
OrderClose(OrderTicket(),0.1,Ask,3,Blue);
ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+Point*StopLoss,Bid-Point*TakeProfit,"firstea",magic,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
}
}
if(total>1){
if(SFCC == 1 && SFCSGreen !=2147483647 && OrderType() == OP_SELL){
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);}
if(SFCC == -1 && SFCSRed !=2147483647 && OrderType() == OP_BUY){
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);}
}
/*
if(total<1){
if(ma13_TF15 && ma26_TF15 > ma223_TF15){
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-Point*StopLoss,Ask+Point*TakeProfit,"firstea",0,0,Blue);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
}
if(ma13_TF15 && ma26_TF15 < ma223_TF15){
ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+Point*StopLoss,Bid-Point*TakeProfit,"firstea",0,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
}
}
*/
if(OrderType() == OP_BUY)
{
if(trailingStop > 0)
{
if(Bid - OrderOpenPrice() > trailingStop*Point)
{
if(OrderStopLoss()==0 || (Bid - OrderStopLoss()> trailingStop*Point))
OrderModify(OrderTicket(), OrderOpenPrice(),
Bid - trailingStop*Point, OrderTakeProfit(), 0, Blue);
}
}
}
else
{
if(trailingStop > 0)
{
if(OrderOpenPrice() - Ask > trailingStop*Point)
{
if(OrderStopLoss() == 0 || OrderStopLoss()-Ask > trailingStop*Point)
OrderModify(OrderTicket(), OrderOpenPrice(),
Ask + trailingStop*Point, OrderTakeProfit(), 0, Red);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
มันขึ้น orderClose error 4108 อ่ะครับ
ผมเขียนผิดตรง ไหนหรอครับ
ขอบคุณครับ