HELP ME !!!!!

HELP ME !!!!!

HELP ME !!!!!

dtyanmm

Active Member
233
95
Thread cover
public/socialthumb.png
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
Mô Hình Biểu Đồ - Phương Pháp Hiệu Quả Để Tìm Kiếm Lợi Nhuận

Được xem là cẩm nang về mô hình biểu đồ của các nhà đầu tư, giao dich tài chính toàn cầu và là kiến thức bắt buộc phải nắm về Phân Tích Kỹ Thuật
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

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

Miễn trừ trách nhiệm

Tất cả nội dung trên website này đều vì mục đích cung cấp thông tin và không phải lời khuyên đầu tư.

Tại Việt Nam, giao dịch CFD forex có các rủi ro nhất định, trong đó bao gồm rủi ro về pháp lý. Độc giả nên tìm hiểu kỹ trước khi đưa ra quyết định tham gia.