double lasthigh;
double lastlow;
double high;
double low;
int trend;
double EMA40 = ......... (ยังไม่แน่ว่าใช้อันนี้)
double EMA80 = ......... (ยังไม่แน่ว่าใช้อันนี้)
lasthigh = High[iHighest(NULL,0,2,400,101)];
lastlow = Low[iLowest(NULL,0,2,400,101)];
double high = High[iHighest(NULL,0,3,100,1)];
double low = Low[iLowest(NULL,0,3,100,1)];
int start()
{
if((total<1) && ((high>lasthigh) || (low<lastlow)))
{
if((EMA40 > EMA80) && (high>lasthigh))
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,0,0,"Long",0,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("buy");
}
if((EMA40 < EMA80) && (low<lastlow))
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,0,0,0,"Short",0,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("sale");
}
trend = 1;
return(0);
}
if(total>0)
{
if(((trend>1)&&(trend<5)&&(OrderType() == OP_BUY)&&(((EMA40 >((EMA80)) || ((trend>1)&&(trend<5)&&(OrderType() == OP_SELL)&&(low<lastlow)))
{
trend = 1;
return(0);
}
///trend = 1 ///
if ((trend>0)&&(trend<2))
{
if((((EMA40 >EMA80)&&(OrderType() == OP_BUY))
{
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,Blue);
Print("sale");
return(0);
}
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,0,0,0,"Short",0,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("sale");
}
}
if((((EMA40 <EMA80)&&(OrderType() == OP_SELL))
{
{
OrderClose(OrderTicket(),OrderLots(),Ask,0,Blue);
Print("buy");
return(0);
}
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,0,0,"Long",0,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("buy");
}
}
trend = 2;
return(0);
}
///trend = 2 ///
if ((trend>1)&&(trend<3))
{
if((((EMA40 >EMA80)&&(OrderType() == OP_BUY))
{
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,Blue);
Print("sale");
return(0);
}
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,0,0,0,"Short",0,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("sale");
}
}
if((((EMA40 <EMA80)&&(OrderType() == OP_SELL))
{
{
OrderClose(OrderTicket(),OrderLots(),Ask,0,Blue);
Print("buy");
return(0);
}
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,0,0,"Long",0,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("buy");
}
}
trend = 3;
return(0);
}
/// trend = 3 ///
if ((trend>2)&&(trend<4))
{
if((((EMA40 >EMA80)&&(OrderType() == OP_BUY))
{
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,Blue);
Print("sale");
return(0);
}
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,0,0,0,"Short",0,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("sale");
}
}
if((((EMA40 <EMA80)&&(OrderType() == OP_SELL))
{
{
OrderClose(OrderTicket(),OrderLots(),Ask,0,Blue);
Print("buy");
return(0);
}
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,0,0,"Long",0,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
Print("buy");
}
}
trend = 4;
return(0);
}
/// trend = 4 ///
if ((trend>3)&&(trend<5))
{
if((((EMA40 >EMA80)&&(OrderType() == OP_BUY))
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,Blue);
Print("sale");
return(0);
}
if((((EMA40 <EMA80)&&(OrderType() == OP_SELL))
{
OrderClose(OrderTicket(),OrderLots(),Ask,0,Blue);
Print("buy");
return(0);
}
return(0);
}
}
return(0);
}
มันไม่เวิกไม่แน่ใจว่าผิดไงน่ะ