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
Phương Pháp Wyckoff Hiện Đại - Kỹ thuật Nhận diện Xu hướng Thị trường Tiềm năng

Phương pháp Wyckoff là một phương pháp price action kinh điển và đem lại thành công cho nhiều trader. Phương pháp này là nền tảng của nhiều phương pháp trading nổi tiếng khác
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

  • DuongHuy trong Phân tích Forex - Vàng - Hàng hóa 472 Xem / 45 Trả lời
  • Quíc Óp trong Phân tích Forex - Vàng - Hàng hóa 221 Xem / 2 Trả lời
  • Mạc An trong Phân tích Forex - Vàng - Hàng hóa 574 Xem / 12 Trả lời
  • forex_vn trong Phân tích Forex - Vàng - Hàng hóa 1,749 Xem / 14 Trả lời
  • phaisinh trong Phân tích Forex - Vàng - Hàng hóa 77 Xem / 1 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