HELP ME !!!!!

HELP ME !!!!!

HELP ME !!!!!

dtyanmm

Active Member
233
95
tình hình là em đang mất ngủ vì con EA , mò mãi hk ra , ace cho hỏi làm cách nào để EA gặp trường hợp 1 Buy nó Buy , sau đó khi chưa thanh khoản được trường hợp 1 mà tiếp tục gặp trường hợp 2 là Sell thì nó Sell , em BackTest toàn xổ ra 1 tràn BUY ko thấy cái nào Sell , nhưng khi /*BUY*/ thì nó mới Sell ~.~! và em chắc chắn là Buy với Sell ko bị trùng bar hay thời gian gì cả ... code em viết theo barem của forexeadvisor.com ... đại loại như cái đống code này


int start()
{
double MyPoint=Point;
if(Digits==3 || Digits==5) MyPoint=Point*10;

int A,B,C,D,E,F;
A=1;
B=2:
C=3:
D=4;
E=5;

double TheStopLoss=0;
double TheTakeProfit=0;
if( TotalOrdersCount()>=0 )
{
int result=0;
if((A>C&&B<C) || (C>E&&D<E))
{
result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

}
return(true);
}
if((A>B&&B<C) || (C>D&&D<E))

{
result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(true);
}
}
return(0);
}

int TotalOrdersCount()
{
int result=0;
for(int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (AllPositions || OrderSymbol()==Symbol())
{
TrailingPositions();
if (OrderMagicNumber()==MagicNumber) result++;
{
return (result);
}
}
}

}

return(0);
}


void TrailingPositions()
{
double pBid, pAsk, pp;
//----
pp=MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY)
{
pBid=MarketInfo(OrderSymbol(), MODE_BID);
if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp)
{
if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp)
{
ModifyStopLoss(pBid-TrailingStop*pp);
return;
}
}
}
if (OrderType()==OP_SELL)
{
pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp)
{
if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0)
{
ModifyStopLoss(pAsk+TrailingStop*pp);
return;
}
}
}
}

void ModifyStopLoss(double ldStopLoss)
{
bool fm;
fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
}


//<---- Check for new candle, returns true

bool NewBar()
{
static datetime OldTime = 0;
if(OldTime < Time[0])
{
OldTime = Time[0];
return(true);
}
else
{
return(false);
}
}
 

Giới thiệu sách Trading hay
Khám phá Nghệ thuật Giao dịch Tiền tệ Chuyên nghiệp

Sách được viết bởi FX Trader chuyên nghiệp, có gần 30 năm giao dịch Forex cho các ngân hàng lớn thế giới như Citi, Nomura hay HSBC, đồng thời từng trading cho quỹ đầu cơ có vốn hàng chục triệu đô la
Bạn phải tạo 1 hàm kiểm tra lệnh buy và sell.
int CountOrders(int Type)
{
int count=0;
//---
for(int i=0;i<OrdersTotal();i++)
{
int s=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
//if(s==false) break;

if(OrderSymbol()==Symbol() && OrderMagicNumber()==vMagic)
{
if(OrderType()==Type) count++;
}

}
return(count);

}
 
Bạn phải tạo 1 hàm kiểm tra lệnh buy và sell.
int CountOrders(int Type)
{
int count=0;
//---
for(int i=0;i<OrdersTotal();i++)
{
int s=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
//if(s==false) break;

if(OrderSymbol()==Symbol() && OrderMagicNumber()==vMagic)
{
if(OrderType()==Type) count++;
}

}
return(count);

}
int TotalOrdersCount()
{
int result=0;
for(int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (AllPositions || OrderSymbol()==Symbol())
{
TrailingPositions();
if (OrderMagicNumber()==MagicNumber) result++;
{
return (result);
}
}
}

}

return(0);
}


hình như là khúc đó có trong code của EA rồi @fx9327
 
Thua, bạn nhờ anh em fix code mà ko post nổi full code lên thì làm sao anh em giúp được :))

Ngay code bạn up lên cũng bị lỗi logic rồi.
 

BÌNH LUẬN MỚI NHẤT

  • Quíc Óp trong Phân tích Forex - Vàng - Hàng hóa 268 Xem / 2 Trả lời
  • Nhật Hoài trong Lập trình MQL - Expert Advisor - Indicator 160,614 Xem / 1,105 Trả lời
  • DuongHuy trong Phân tích Forex - Vàng - Hàng hóa 369 Xem / 21 Trả lời
  • Mạc An trong Phân tích Forex - Vàng - Hàng hóa 755 Xem / 21 Trả lời
  • DuongHuy trong Phân tích Forex - Vàng - Hàng hóa 319 Xem / 12 Trả lời
  • Mạc An trong Phân tích Forex - Vàng - Hàng hóa 622 Xem / 14 Trả lời
  • AdBlock Detected

    We get it, advertisements are annoying!

    Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

    Back
    Bên trên