Vì sao nên chọn MQL5 để học code thay vì MQL4

Vì sao nên chọn MQL5 để học code thay vì MQL4

Vì sao nên chọn MQL5 để học code thay vì MQL4

QuantTrader

Active Member
287
197
Sau một thời gian làm việc với cả hai ngôn ngữ mình có một số kinh nghiệm muốn chia sẻ với các bạn đã và đang học code về lí do nên học MQL5 như sau:

1. Ưu điểm của lập trình hướng đối tượng:
Như mọi người đã biết MQL4 tương tự ngôn ngữ C còn MQL5 tương tự C++. Tính ưu việt của lập trình hướng đối tượng thì trên mạng nói nhiều rồi riêng mình thấy nếu viết một EA đơn giản thì dùng MQL4 dễ dàng hơn nhiều nhưng khi bạn muốn viết một EA phức tạp hoặc sửa lại một phần của EA thì MQL5 ưu việt hơn giống như chỉ cần thay một bộ phận của chiếc xe thay vì sửa cả chiếc xe nguyên khối vậy.

2. Là ngôn ngữ ưu tiên phát triển của Metaquotes, luôn cập nhật các chức năng mới.
Metaquotes ưu tiên phát triển MQL5 và liên tục cập nhật các chức năng mới, một số chức năng đáng chú ý như:
+ Truy cập trực tiếp thông tin kinh tế: MQL5 có các hàm để lấy trực tiếp thông tin các sự kiện kinh tế trong quá khứ và sắp diễn ra, bạn không phải tìm nguồn, phương thức để tải và đọc các tin này.
+ MQL5 hỗ trợ tích hợp thư viện .NET bạn có thể sử dụng trực tiếp các thư viện và các giao diện được tạo băng Visual Studio. Việc này giúp bạn thiết kế các giao diện phức tạp cho EA và là tiền đề để viết các EA sử dụng trí tuệ nhân tạo.
+ Chức năng mở/đóng lệnh đồng bộ. Ở MQL4 khi bạn mở hoặc đóng một lệnh thì sẽ phải chờ phản hồi từ broker thì lệnh tiếp theo mới thực hiện. Nếu bạn đóng 100 lệnh một lúc thì phải chờ lần lượt từng lệnh đóng, MQL5 thì cho phép đóng luôn 100 lệnh đó một lần.
Đây chỉ là các chức năng nổi bật MQL5 còn có nhiều chức năng khác giúp EA quản lí sâu hơn các hoạt động của EA.

3. Backtest.....Backtest.....Backtest.....
Ở MQL4 bạn test bằng phương pháp "Every tick" nhưng đấy không phải là tick thật mà chỉ là các tick mô phỏng được tạo ra, nó sẽ đúng với các phương pháp ở Timeframe lớn ăn nhiều pips còn các phương pháp ăn chỉ vài pips thì không có tác dụng. Đó là lí do tại sao có nhiều EA test từ vài trăm lên vài triệu đô nhưng đánh real thì thua sấp mặt.
MQL5 có phương pháp test "Every tick base on real tick" dựa trên tick thật của thị trường và hệ thống mô phỏng spread (MQL4 cố định spread ) nên nó là hệ thống test tốt nhất hiện nay giúp bạn tiết kiệm được thời gian và tiền bạc cho việc phát triển EA.

Mặc dù MQL5 có hơi khó học hơn MQL4 nhưng giá trị nó mang lại cũng đáng để bỏ công sức. Chúc các bạn trade thành công !!
 

Giới thiệu sách Trading hay
Đánh Bại Thị Trường Forex - Tư duy khác biệt và các kỹ thuật giao dịch của chuyên gia quản lý quỹ triệu đô

Sách chia sẻ kiến thức và kinh nghiệm trading từ một chuyên gia quản lý quỹ, cùng các kỹ thuật giao dịch giúp quỹ này đứng trong top nhiều năm
Sau một thời gian làm việc với cả hai ngôn ngữ mình có một số kinh nghiệm muốn chia sẻ với các bạn đã và đang học code về lí do nên học MQL5 như sau:

1. Ưu điểm của lập trình hướng đối tượng:
Như mọi người đã biết MQL4 tương tự ngôn ngữ C còn MQL5 tương tự C++. Tính ưu việt của lập trình hướng đối tượng thì trên mạng nói nhiều rồi riêng mình thấy nếu viết một EA đơn giản thì dùng MQL4 dễ dàng hơn nhiều nhưng khi bạn muốn viết một EA phức tạp hoặc sửa lại một phần của EA thì MQL5 ưu việt hơn giống như chỉ cần thay một bộ phận của chiếc xe thay vì sửa cả chiếc xe nguyên khối vậy.

2. Là ngôn ngữ ưu tiên phát triển của Metaquotes, luôn cập nhật các chức năng mới.
Metaquotes ưu tiên phát triển MQL5 và liên tục cập nhật các chức năng mới, một số chức năng đáng chú ý như:
+ Truy cập trực tiếp thông tin kinh tế: MQL5 có các hàm để lấy trực tiếp thông tin các sự kiện kinh tế trong quá khứ và sắp diễn ra, bạn không phải tìm nguồn, phương thức để tải và đọc các tin này.
+ MQL5 hỗ trợ tích hợp thư viện .NET bạn có thể sử dụng trực tiếp các thư viện và các giao diện được tạo băng Visual Studio. Việc này giúp bạn thiết kế các giao diện phức tạp cho EA và là tiền đề để viết các EA sử dụng trí tuệ nhân tạo.
+ Chức năng mở/đóng lệnh đồng bộ. Ở MQL4 khi bạn mở hoặc đóng một lệnh thì sẽ phải chờ phản hồi từ broker thì lệnh tiếp theo mới thực hiện. Nếu bạn đóng 100 lệnh một lúc thì phải chờ lần lượt từng lệnh đóng, MQL5 thì cho phép đóng luôn 100 lệnh đó một lần.
Đây chỉ là các chức năng nổi bật MQL5 còn có nhiều chức năng khác giúp EA quản lí sâu hơn các hoạt động của EA.

3. Backtest.....Backtest.....Backtest.....
Ở MQL4 bạn test bằng phương pháp "Every tick" nhưng đấy không phải là tick thật mà chỉ là các tick mô phỏng được tạo ra, nó sẽ đúng với các phương pháp ở Timeframe lớn ăn nhiều pips còn các phương pháp ăn chỉ vài pips thì không có tác dụng. Đó là lí do tại sao có nhiều EA test từ vài trăm lên vài triệu đô nhưng đánh real thì thua sấp mặt.
MQL5 có phương pháp test "Every tick base on real tick" dựa trên tick thật của thị trường và hệ thống mô phỏng spread (MQL4 cố định spread ) nên nó là hệ thống test tốt nhất hiện nay giúp bạn tiết kiệm được thời gian và tiền bạc cho việc phát triển EA.

Mặc dù MQL5 có hơi khó học hơn MQL4 nhưng giá trị nó mang lại cũng đáng để bỏ công sức. Chúc các bạn trade thành công !!
Qúa hay ! đáng chú ý đến MQL5. Nếu chuyển .mq4 thành .mq5 bằng phần mềm, vậy cái EA đó chạy trên MT5 có giống với MT4 không bác ? và chuyển bằng phần mềm trong tương lai có khả thi không bác ?
Cám ơn bác
 
Qúa hay ! đáng chú ý đến MQL5. Nếu chuyển .mq4 thành .mq5 bằng phần mềm, vậy cái EA đó chạy trên MT5 có giống với MT4 không bác ? và chuyển bằng phần mềm trong tương lai có khả thi không bác ?
Cám ơn bác
Thường thì mình viết trên MQL5 sau đó chuyển về MQL4 khá nhanh. Chuyển bằng phần mềm mình nghĩ khả thi vì chỉ cần thay thế một số code cố định thôi, nếu chuyển thành công thì EA vẫn hoạt động như ở MT4.
 
Thường thì mình viết trên MQL5 sau đó chuyển về MQL4 khá nhanh. Chuyển bằng phần mềm mình nghĩ khả thi vì chỉ cần thay thế một số code cố định thôi, nếu chuyển thành công thì EA vẫn hoạt động như ở MT4.
Ở đây thấy có dân lập trình như bác là "best good".
 
Thường thì mình viết trên MQL5 sau đó chuyển về MQL4 khá nhanh. Chuyển bằng phần mềm mình nghĩ khả thi vì chỉ cần thay thế một số code cố định thôi, nếu chuyển thành công thì EA vẫn hoạt động như ở MT4.
bác có thể m cho hỏi như dưới đây:

int start()
{
string EURUSD;
double Close_0 = iClose(EURUSD,0,0);
Comment("Close0 = " + string(Close_0);
}
Nếu mình muốn gán cho nó bất kì đồ thị cặp nào khác, thì nó vẫn lấy chỉ số trên đồ thị cặp EURUSD, thì làm thế nào hả bác ?
CẢM ƠN BÁC
 
bác có thể m cho hỏi như dưới đây:

int start()
{
string EURUSD;
double Close_0 = iClose(EURUSD,0,0);
Comment("Close0 = " + string(Close_0);
}
Nếu mình muốn gán cho nó bất kì đồ thị cặp nào khác, thì nó vẫn lấy chỉ số trên đồ thị cặp EURUSD, thì làm thế nào hả bác ?
CẢM ƠN BÁC
Ko biết ý bạn là thế nào về "gán cho nó bất kì đồ thị cặp nào khác" . Nhưng nếu là iClose thì thông số đầu tiên là tên cặp, nếu lấy cặp mà EA đang chạy trên đó thì dùng iClose(Symbol(),...) hoặc iClose(_Symbol,...) còn muốn lấy một cặp cụ thể thì cứ việc thêm tên cặp đó vào iClose("EURUSD",...) , iClose("GBPUSD",...) ..vv
 
Ko biết ý bạn là thế nào về "gán cho nó bất kì đồ thị cặp nào khác" . Nhưng nếu là iClose thì thông số đầu tiên là tên cặp, nếu lấy cặp mà EA đang chạy trên đó thì dùng iClose(Symbol(),...) hoặc iClose(_Symbol,...) còn muốn lấy một cặp cụ thể thì cứ việc thêm tên cặp đó vào iClose("EURUSD",...) , iClose("GBPUSD",...) ..vv
Cảm ơn bác, e cho tên cặp đó vào trong 2 cái ngoặc kép đc rồi, nhưng khi em không muốn cho tên cặp đó vào ngoặc kép mà thay bằng gọi kiểu string thì lại không đc ? kiểu string và 2 cái ngoặc kép là tương đương nhau mà pải không bác ?
 
Bác đang dùng sai ở chổ
EURUSD
ở đoạn lệnh bên dưới của bác đang là tên biến chưa có giá trị chứ chưa phải là tên cặp tiền EURUSD

int start()
{
string EURUSD;
double Close_0 = iClose(EURUSD,0,0);
Comment("Close0 = " + string(Close_0);
}

Bác cần sửa lại như sau:
int start()
{
string Sym = "
EURUSD";
double Close_0 = iClose(
Sym,0,0);
Comment("Close0 = " + string(Close_0);
}
Cám ơn bác em hiểu rõ vấn rồi !
 
Bác cho e hỏi e đang học lập trình mà e đang vấp phải chỗ không biết chọn đỉnh cao nhất và 1 đỉnh để ra trend line và đợi phá vỡ vào lệnh ( e đang lập trình ea có nhiều thứ ngu nguội mong bác thông não ) em cảm ơn ạ
 
Bạn có thể hướng dẫn mình cách đọc về thời điểm tin xảy ra trong mql5 từ forex calender được không. Mình mới vọc

ví dụ trả về mảng datetime của các tin cho cặp EU xảy ra trong khoảng +/- 6hr.

Cám ơn trước nhé.
 
Sau một thời gian làm việc với cả hai ngôn ngữ mình có một số kinh nghiệm muốn chia sẻ với các bạn đã và đang học code về lí do nên học MQL5 như sau:

1. Ưu điểm của lập trình hướng đối tượng:
Như mọi người đã biết MQL4 tương tự ngôn ngữ C còn MQL5 tương tự C++. Tính ưu việt của lập trình hướng đối tượng thì trên mạng nói nhiều rồi riêng mình thấy nếu viết một EA đơn giản thì dùng MQL4 dễ dàng hơn nhiều nhưng khi bạn muốn viết một EA phức tạp hoặc sửa lại một phần của EA thì MQL5 ưu việt hơn giống như chỉ cần thay một bộ phận của chiếc xe thay vì sửa cả chiếc xe nguyên khối vậy.

2. Là ngôn ngữ ưu tiên phát triển của Metaquotes, luôn cập nhật các chức năng mới.
Metaquotes ưu tiên phát triển MQL5 và liên tục cập nhật các chức năng mới, một số chức năng đáng chú ý như:
+ Truy cập trực tiếp thông tin kinh tế: MQL5 có các hàm để lấy trực tiếp thông tin các sự kiện kinh tế trong quá khứ và sắp diễn ra, bạn không phải tìm nguồn, phương thức để tải và đọc các tin này.
+ MQL5 hỗ trợ tích hợp thư viện .NET bạn có thể sử dụng trực tiếp các thư viện và các giao diện được tạo băng Visual Studio. Việc này giúp bạn thiết kế các giao diện phức tạp cho EA và là tiền đề để viết các EA sử dụng trí tuệ nhân tạo.
+ Chức năng mở/đóng lệnh đồng bộ. Ở MQL4 khi bạn mở hoặc đóng một lệnh thì sẽ phải chờ phản hồi từ broker thì lệnh tiếp theo mới thực hiện. Nếu bạn đóng 100 lệnh một lúc thì phải chờ lần lượt từng lệnh đóng, MQL5 thì cho phép đóng luôn 100 lệnh đó một lần.
Đây chỉ là các chức năng nổi bật MQL5 còn có nhiều chức năng khác giúp EA quản lí sâu hơn các hoạt động của EA.

3. Backtest.....Backtest.....Backtest.....
Ở MQL4 bạn test bằng phương pháp "Every tick" nhưng đấy không phải là tick thật mà chỉ là các tick mô phỏng được tạo ra, nó sẽ đúng với các phương pháp ở Timeframe lớn ăn nhiều pips còn các phương pháp ăn chỉ vài pips thì không có tác dụng. Đó là lí do tại sao có nhiều EA test từ vài trăm lên vài triệu đô nhưng đánh real thì thua sấp mặt.
MQL5 có phương pháp test "Every tick base on real tick" dựa trên tick thật của thị trường và hệ thống mô phỏng spread (MQL4 cố định spread ) nên nó là hệ thống test tốt nhất hiện nay giúp bạn tiết kiệm được thời gian và tiền bạc cho việc phát triển EA.

Mặc dù MQL5 có hơi khó học hơn MQL4 nhưng giá trị nó mang lại cũng đáng để bỏ công sức. Chúc các bạn trade thành công !!

Bạn có nhận code MT5 không?
 
### POST HƠI CŨ HI VỌNG CÓ CAO NHÂN CHỈ ĐIỂM ###
Hiện em đang muốn học lập trình EA, xu hướng 2020 này nên nhảy vào học luôn mql5 hay học từ mql4 để bắt kịp xu hướng trong vài năm tới ạ ! Tuy nhiên thì hiện giờ mql5 cộng đồng khá ít.:confused::confused::confused:. Cho em xin vài nguồn tự học mql5 cho beginer luôn ạ, vì em cũng chưa có background của mql4
Em cám ơn
 
Bác muốn code gì ở MT5? Inbox cho tôi nhé!
Con EA này muốn chuyển thành MQL5 thì như thế nào hả bác.
và mình muốn nó tự tính lost 1% thì có được không ạ?

//+------------------------------------------------------------------+
extern int MagicNumber = 10000;
extern double Lots = 0.01;
extern double StopLoss = 12;
extern double TakeProfit1 = 0;
extern double TakeProfit2 = 15;
extern double TakeProfit3 = 18;
extern double TakeProfit4 = 21;
extern double TakeProfit5 = 24;
extern double TakeProfit6 = 27;
extern double TakeProfit7 = 30;
extern double TakeProfit8 = 33;
extern double TakeProfit9 = 36;
extern int TrailingStop = 12;
extern int Slippage = 3;
//+------------------------------------------------------------------+
// expert start function
//+------------------------------------------------------------------+
int start()
{double MyPoint=Point;
if(Digits==1 || Digits==2|| Digits==3|| Digits==4|| Digits==5|| Digits==6|| Digits==7|| Digits==8|| Digits==9) {MyPoint=Point*10;}
double TheStopLoss=0;
double TheTakeProfit1=0;double TheTakeProfit2=0;double TheTakeProfit3=0;double TheTakeProfit4=0;double TheTakeProfit5=0;
double TheTakeProfit6=0;double TheTakeProfit7=0;double TheTakeProfit8=0;double TheTakeProfit9=0;
if(TotalOrdersCount()==0)
{int result1=0; int result2=0;int result3=0;int result4=0;int result5=0; int result6=0;int result7=0;int result8=0;int result9=0;
if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Ask+TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);

result2= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Ask+TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);

result3= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Ask+TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);

result4= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Ask+TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);

result5= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Ask+TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);

result6= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Ask+TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);

result7= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Ask+TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);

result8= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Ask+TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);

result9= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Ask+TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}

//======================================================================================================

if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Bid-TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);

result2= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Bid-TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);

result3= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Bid-TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);

result4= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Bid-TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);

result5= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Bid-TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);

result6= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Bid-TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);

result7= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Bid-TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);

result8= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Bid-TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);

result9= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Bid-TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}}
//======================================================================================================
for(int cnt=0;cnt<OrdersTotal();cnt++)
{OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{if(OrderType()==OP_BUY)
{if(TrailingStop>0)
{if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
{OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
return(0);}}}}
else
{if(TrailingStop>0)
{if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
{if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
{OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
return(0);}}}}}} return(0);}
int TotalOrdersCount()
{int result=0;
for(int i=0;i<OrdersTotal();i++)
{OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;}
return (result);}
//======================================================================================================
Anh em nào cần học MQL5 thì liên hệ nhé, zalo: 0902780588 or https://www.facebook.com/hoclaptrinhrobotmt5mt4/
 
Thường thì mình viết trên MQL5 sau đó chuyển về MQL4 khá nhanh. Chuyển bằng phần mềm mình nghĩ khả thi vì chỉ cần thay thế một số code cố định thôi, nếu chuyển thành công thì EA vẫn hoạt động như ở MT4.
Bác chuyển giúp em con EA này thành MQL5 và tự động tính lost 1 % được không ạ? em xin cảm ơn nhiều.

//+------------------------------------------------------------------+
extern int MagicNumber = 10000;
extern double Lots = 0.01;
extern double StopLoss = 12;
extern double TakeProfit1 = 0;
extern double TakeProfit2 = 15;
extern double TakeProfit3 = 18;
extern double TakeProfit4 = 21;
extern double TakeProfit5 = 24;
extern double TakeProfit6 = 27;
extern double TakeProfit7 = 30;
extern double TakeProfit8 = 33;
extern double TakeProfit9 = 36;
extern int TrailingStop = 12;
extern int Slippage = 3;
//+------------------------------------------------------------------+
// expert start function
//+------------------------------------------------------------------+
int start()
{double MyPoint=Point;
if(Digits==1 || Digits==2|| Digits==3|| Digits==4|| Digits==5|| Digits==6|| Digits==7|| Digits==8|| Digits==9) {MyPoint=Point*10;}
double TheStopLoss=0;
double TheTakeProfit1=0;double TheTakeProfit2=0;double TheTakeProfit3=0;double TheTakeProfit4=0;double TheTakeProfit5=0;
double TheTakeProfit6=0;double TheTakeProfit7=0;double TheTakeProfit8=0;double TheTakeProfit9=0;
if(TotalOrdersCount()==0)
{int result1=0; int result2=0;int result3=0;int result4=0;int result5=0; int result6=0;int result7=0;int result8=0;int result9=0;
if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Ask+TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);

result2= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Ask+TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);

result3= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Ask+TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);

result4= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Ask+TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);

result5= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Ask+TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);

result6= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Ask+TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);

result7= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Ask+TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);

result8= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Ask+TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);

result9= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Ask+TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}

//======================================================================================================

if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Bid-TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);

result2= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Bid-TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);

result3= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Bid-TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);

result4= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Bid-TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);

result5= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Bid-TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);

result6= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Bid-TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);

result7= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Bid-TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);

result8= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Bid-TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);

result9= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Bid-TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}}
//======================================================================================================
for(int cnt=0;cnt<OrdersTotal();cnt++)
{OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{if(OrderType()==OP_BUY)
{if(TrailingStop>0)
{if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
{OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
return(0);}}}}
else
{if(TrailingStop>0)
{if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
{if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
{OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
return(0);}}}}}} return(0);}
int TotalOrdersCount()
{int result=0;
for(int i=0;i<OrdersTotal();i++)
{OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;}
return (result);}
//======================================================================================================
 
Hello, mình đang vọc MQL5 được vài tháng, nhờ các bạn đi trước giải đáp giúp thắc mắc ngây ngô của mình với:
1/ Để chuẩn bị dataset có tính đầy đủ và liên tục thì MQLer chuyên nghiệp sẽ làm như thế nào nhỉ? Hiện tại mình làm bằng cách export data từ MT5 và append data tiếp tục bằng Python.
2/ Các giá trị missed (NaN:?) trong thị trường là gì? Các bạn đã đánh giá và điền thiếu như thế nào?
3/ Có group trò chuyện nào cần người giúp việc hem? Cho mình xin vào group để được nói chuyện với, làm gì cũng mình ên buồn quá :(.

Cảm ơn đã đọc câu hỏi, hi vọng sẽ có người trả lời, chúc diễn đàn sức khỏe!
 

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

  • ngoi_sao_co_doc trong Phân tích Forex - Vàng - Hàng hóa 24,498 Xem / 87 Trả lời
  • Quíc Óp trong Phân tích Forex - Vàng - Hàng hóa 347 Xem / 19 Trả lời
  • Mạc An trong Phân tích Forex - Vàng - Hàng hóa 874 Xem / 39 Trả lời
  • TraderViet Crypto trong Chuyện bên lề 276 Xem / 2 Trả lời
  • DuongHuy trong Phân tích Forex - Vàng - Hàng hóa 393 Xem / 31 Trả lời
  • Bianas trong Phân tích Forex - Vàng - Hàng hóa 145 Xem / 3 Trả lời
  • Huan2051 trong Phân tích Forex - Vàng - Hàng hóa 294,759 Xem / 1,397 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