รายการตรวจสอบแหล่งที่มา MQL

MetaTrader 4
GogoJungle
2023/04/13 20:06
109

เกี่ยวกับรายการตรวจสอบซอร์สโค้ด MQL

ฉันจะอธิบายเนื้อหาของการตรวจสอบซอร์สโค้ด MQL ที่ดำเนินการโดย Gogojan
เราหวังว่าคุณจะใช้เป็นรายการตรวจสอบเมื่อลงรายการ EA ของคุณ


ขั้นตอนการตรวจสอบ EA ทั้งหมดมีดังนี้

  1. ตรวจสอบซอร์สโค้ด (mq4)
  2. ทดสอบย้อนหลังและตรวจสอบกับ Strategy Tester
  3. ตรวจสอบโดยดำเนินการกับบัญชีทดลอง

*โปรดทราบว่าการตรวจสอบนี้ไม่รับประกันผลลัพธ์ของ EA


ที่นี่ ฉันจะอธิบายเนื้อหาการตรวจสอบเฉพาะของซอร์สโค้ด (mq4)

1. การจัดการพารามิเตอร์

1-1.ยืนยันการตั้งค่าเลขวิเศษ

  • การตั้งค่าสามารถเปลี่ยนเป็นค่าใดก็ได้ตามพารามิเตอร์
[Example
extern int MagicNumber = 123456;
input int MAGIC = 123456;

1-2. การยืนยันการเปลี่ยนเลขวิเศษ (อัพเกรด)

  • ตรวจสอบให้แน่ใจว่าหมายเลขเวทย์มนตร์นั้นเหมือนกับครั้งที่แล้ว (ค้นหาด้วย extern หรือ input เพื่อยืนยัน)

2. การบริหารตำแหน่ง

2-1 การยืนยันการประมวลผลการนับตำแหน่ง

  • กำหนดคู่สกุลเงินและตัวเลขมหัศจรรย์ และนับจำนวนตำแหน่ง (ค้นหา OrdersTotal เพื่อยืนยัน)
[Example.
      //-------- entering a new position --------
      // Count the number of positions
      for(i=OrdersTotal()-1; i>=0; i--)
      {
         // Select orders (if an error occurs, break out of the loop)
         if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false)
         {
            Print("OrderSelect returned the error of ", GetLastError() );
            break; }
         }
         
         // Order confirmation (if the currency pair does not match, return to the beginning of the for statement)
         if (OrderSymbol() ! = Symbol()) continue; }
         
         //Confirm magic number (if the magic number does not match, return to the top of the for statement)
         if (OrderMagicNumber() ! = MagicNumber) continue; if (OrderMagicNumber() !
   
         if (OrderType() == OP_BUY)
         {
            CountBuy = CountBuy + 1; }
         }
         
         if (OrderType() == OP_SELL)
         {
            CountSell = CountSell + 1; }
         }
      }     

3. การประมวลผลรายการ

3-1 ตรวจสอบจำนวนตำแหน่งสูงสุด

  • ตามข้อกำหนดเบื้องต้น จะต้องเปรียบเทียบและตัดสินจำนวนตำแหน่งปัจจุบันและจำนวนตำแหน่งสูงสุด (ค้นหาด้วย OrderSend เพื่อยืนยัน)
[Example
if (countbuy<MaxPos) { 
   int ticket = -1;
   ticket=OrderSend(NULL,OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber,0,Blue);

3-2.ยืนยันการตั้งค่าเลขมหัศจรรย์

  • ต้องตั้งค่าตัวเลขมหัศจรรย์ (ระบุใน 1-1.) เมื่อสร้างรายการ (อาร์กิวเมนต์ที่ 9 ในฟังก์ชัน OrderSend)
[Example.
OrderSend(NULL,OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber",0,Blue);

3-3.ยืนยันการตั้งค่าคู่สกุลเงิน

  • คู่สกุลเงินต้องเป็น Symbol() หรือ NULL เมื่อทำรายการ (ในฟังก์ชัน OrderSend)
    (หากได้รับการแก้ไข ควรพิจารณาอักขระโดยโบรกเกอร์ เช่น USDJPYm, USDJPY_)
[Example
OrderSend("Symbol()",OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber,0,Blue);

3-4. การยืนยันการตั้งค่า stop loss (เมื่อไม่มีการชำระลอจิกโดย OrderClose: เมื่อชำระ SL และ TP เท่านั้น)

  • การตั้งค่าหยุดการขาดทุนถูกกำหนด ณ เวลาที่เข้า (ค้นหา OrderClose เพื่อยืนยัน)
  • ตรวจสอบด้วยอาร์กิวเมนต์ 5 ตัว (*ตัวที่ 5 เว้นได้)
  • ยืนยันการเปลี่ยนแปลงคำสั่งสำหรับตำแหน่งจำกัด/หยุด

ต่อไปนี้เป็นตัวอย่าง NG เนื่องจาก SL และ TP จะไม่ถูกตั้งค่าอีกหาก OrderModify ล้มเหลว

[NG Example.
if( EntryPosition == 1 ) //Entry condition for buy.
{
	 res=OrderSend(Symbol(),OP_BUY,Lots ,Ask,SLP,0,0, "TrendLogic",MAGIC,0,Red);
	 if (OrderSelect(res,SELECT_BY_TICKET)==true)
	 {
		 if (Buy_stoploss!=0) SL=OrderOpenPrice()-Buy_stoploss*AdjustPoint(Symbol());
		 if (Buy_takeprofit!=0) TP=OrderOpenPrice()+Buy_takeprofit*AdjustPoint(Symbol());
	 }
	 Modified=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,Red); }
}
else if(EntryPosition == -1 ) //---- SellEntry
{
	 res=OrderSend(Symbol(),OP_SELL,Lots,Bid,SLP,0,0, "TrendLogic",MAGIC,0,White); }
	 if(OrderSelect(res,SELECT_BY_TICKET)==true)
	 {
		 if(Sell_stoploss!=0) SL=OrderOpenPrice()+Sell_stoploss*AdjustPoint(Symbol());
		 if(Sell_takeprofit!=0) TP=OrderOpenPrice()-Sell_takeprofit*AdjustPoint(Symbol());
	 }
	 Modified=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,White); }
}
  • เมื่อทำข้อเสนอให้กับบริษัทหลักทรัพย์ ให้ตรวจสอบการตั้งค่าหยุดการขาดทุนโดยไม่คำนึงถึงตรรกะ

`ต่อไปนี้เป็นวิธีบังคับให้ตั้งค่า sl,tp เมื่อสั่งซื้อ’

[Before modification
ticket=OrderSend(symbol,OP_BUY,Lots,Ask,Slippage,0,0,NULL,MagicNumber,0,Blue);
if(ticket>=0)
	if(OrderModify(ticket,OrderOpenPrice(),sl,tp,0))
	{
		lastTime=now;
		entry_cnt++;
	}
[After modification
ticket=OrderSend(symbol,OP_BUY,Lots,Ask,Slippage,sl,tp,NULL,MagicNumber,0,Blue);
if(ticket>=0)
	{
		lastTime=now;
		entry_cnt++;
	}

3-5. การยืนยันขั้นตอนการคำนวณล็อต (หากล็อตเป็นตัวแปร: การทบทุน, ดอกเบี้ยทบต้น ฯลฯ)

  • เมื่อเริ่ม MT4 ใหม่ ตัวแปรจะถูกเตรียมใช้งาน (เนื่องจากไม่ได้รับมาใหม่) และการประมวลผลตามเงื่อนไขที่ส่งผลต่อลอจิกจะไม่เกิดขึ้น

4.ดำเนินการชำระเงิน

4-1. การยืนยันเลขมหัศจรรย์

  • ตามข้อกำหนดเบื้องต้น จะต้องกำหนดหมายเลขเวทย์มนตร์และคู่สกุลเงิน
[Example.
for( i=OrdersTotal()-1; i>=0; i-- ){
  if( OrderSelect(i, SELECT_BY_POS) == true ){
    if( OrderType() == OP_BUY && OrderMagicNumber() == Magic && OrderSymbol() == Symbol() ){
      if( ! (OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,Green)){

4-2 การยืนยันตั๋วสำหรับการชำระเงิน

  • หลังจากกำหนดหมายเลขเวทมนตร์และคู่สกุลเงินแล้ว ตั๋วที่จะตัดสินจะต้องไม่เปลี่ยนแปลง (ต้องไม่ดำเนินการเลือกคำสั่งซื้อขาย)

`ต่อไปนี้เป็น NG เนื่องจากตั๋ว ณ เวลาที่ชำระเงินเปลี่ยนรูปแบบ’

for( i=OrdersTotal()-1; i>=0; i-- ){
  if( OrderSelect(i, SELECT_BY_POS) == true ){
    if( OrderType() == OP_BUY && OrderMagicNumber() == Magic && OrderSymbol() == Symbol() ){
      OrderTicketChange();.
      if( ! (OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,Green)){
void OrderTicketChange()
  {
   OrderSelect(3, SELECT_BY_POS); }   
  }

4-3 การยืนยันการลองดำเนินการใหม่

  • แม้ว่าข้อตกลงจะล้มเหลวเพียงครั้งเดียว การตัดสินและการประมวลผลข้อตกลงควรดำเนินการอีกครั้งทุก ๆ การติ๊ก (ควรคำนึงถึงความล้มเหลวในการยุติข้อตกลง)

NG สำหรับการประมวลผลลูปไม่สิ้นสุด

[Example.
bool closePosition(int magic, int type = -1) //function to process settlement.
{
   int result_count = 0; //number of attempts
   int close_signal = 0; //0 means success, non-zero means failure

   if(IsTradeAllowed() == true) {
      for(int i = OrdersTotal() - 1; i >= 0; i--) {
         if(OrderSelect(i, SELECT_BY_POS) == false) continue;
         if(OrderSymbol() ! = Symbol() || OrderMagicNumber() ! = magic) continue; if(type >= 0 &&
         if(type >= 0 && OrderType() ! = type) continue; if(OrderType() !
         RefreshRates(); if(OrderClose(OrderType() !

if(OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, ArrowColor[OrderType()]) == true) {
            continue; //first close process (usually succeeds here)
         }else{ //processing in case of settlement failure from here
            result_count = 0; for(int j = 0; j = 0; j = 0; j = 0; j = 0
            for(int j = 0; j < RETRY_COUNT; j++) { //repeat processing until retry count is reached
               Sleep(200);

               if(OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, ArrowColor[OrderType()]) == true) { 
                  break; //exit from the loop if successful
               }else{ //in case of failure
                  int err = GetLastError();
                  if(err > 0){
                     result_count++; //increase the counter for the number of failures
                     Print("[OrderClose Error] : ", err, " ", ErrorDescription(err)); }
                  }
               }
               if(result_count == RETRY_COUNT) { //when the counter reaches the specified number of attempts
                  close_signal++; //signal settlement failure
               }
            }
         }
   }
      if(close_signal == 0) return(true); //exit the function because of success
      Alert("[OrderClose Error] : Close timeout. Check the experts log."); //Timeout error on failure  
   }
   return(false); //Alert and exit the function.
}

4-4.ยืนยันเงื่อนไขการชำระเงิน

  • เมื่อเริ่ม MT4 ใหม่ ตัวแปรจะถูกเตรียมใช้งาน (เนื่องจากไม่ได้รับมาใหม่) และการประมวลผลตามเงื่อนไขที่ส่งผลต่อลอจิกจะไม่เกิดขึ้น

NG ถ้าตัวแปรที่ใช้สำหรับเงื่อนไขการชำระถูกเริ่มต้นโดยการรีสตาร์ท

5. การจัดการข้อยกเว้น

5-1 การยืนยันการจัดการข้อผิดพลาด

  • การประมวลผลแบบวนซ้ำ ‘ในขณะที่’ ต้องไม่เป็นการวนซ้ำไม่สิ้นสุด (ต้องครอบคลุมรูปแบบการจัดการข้อผิดพลาด)
[Good example: Timeout handling is described.
while(true)
{
int hoge; //variable that becomes 1 when processing is successful

   //**** where processing such as settlement***//

if(hoge) return(true);

   // timeout processing
   if (GetTickCount() - StartTime > 10 * 1000)
   {
      Alert("OrderSend timeout. Check the experts log."); { return(-1); }
      
      return(-1); }
   }
[Bad example: timeout processing is not described.
while(true)
{
int hoge; //variable that becomes 1 if processing is successful

   //**** where processing such as settlement***//

if(hoge) return(true); }
   }
[Other examples of loop escaping
// If the error is not resolved by retrying, escape the loop
if(err == ERR_INVALID_PRICE) break; }
if(err == ERR_INVALID_STOPS) break;
if(err == ERR_LONGS_NOT_ALLOWED) break; break
if(err == ERR_SHORTS_NOT_ALLOWED) break; if(err == ERR_SHORTS_NOT_ALLOWED) break;
if(err == ERR_NOT_ENOUGH_MONEY) break; break
if(err == ERR_TRADE_TOO_MANY_ORDERS) break; if(err == ERR_TRADE_TOO_MANY_ORDERS)

6. ขีดจำกัดการซื้อขาย

6-1 การยืนยันวงเงินการทำธุรกรรม

  • ทำงานกับบริษัทหลักทรัพย์หลายแห่ง (ไม่จำกัดนายหน้า หลักสูตร เลขที่บัญชี ชื่อไฟล์)
[NG Example: Specifying a brokerage firm (Gaitame)
int OnInit()
{
   if(IsTradeAllowed() == false) {
      Alert("Enable the setting 'Allow live trading' in the Expert Properties!"); }
   }
   if(StringFind(TerminalInfoString(TERMINAL_COMPANY), "Gaitame") == -1) return(INIT_FAILED); //If the brokerage is not "Gaitame", initialization will fail


   magic_array[0] = Magic1;
   bars1 = getBars(Magic1);

   return(INIT_SUCCEEDED); }
}

7.การประมวลผลภายนอก

7-1 การยืนยันการสื่อสารภายนอก

  • ยืนยันว่าไม่มีการสื่อสารภายนอกและการสื่อสารไฟล์ (ตรวจสอบโดยค้นหาด้วย http)
  • ยืนยันว่าไม่มีลิงค์ภายนอก (หากมีลิงค์อื่นนอกเหนือจากของบริษัทเรา)

7-2 การตรวจสอบไฟล์ภายนอก

  • ไม่ใช้เพื่อวัตถุประสงค์ในการเพิ่มประสิทธิภาพผล backtest (ค้นหา hst, dll เพื่อยืนยัน)

7-3 ตรวจสอบตัวแปรส่วนกลาง

  • ไม่ได้ใช้ตัวแปรส่วนกลาง (GlobalVariableSet, GlobalVariableGet)
    (เมื่อใช้งาน ให้เข้าใจลักษณะของตัวแปรโกลบอลและนำไปใช้โดยไม่มีปัญหา)

8. คอมเม้นเพื่อการซื้อขายจริง

8-1.Confirm OrderSend ความคิดเห็นโต้แย้ง

  • ในกระบวนการเข้าร่วม ความคิดเห็นสำหรับการซื้อขายจริงจะถูกนำไปใช้กับความคิดเห็นที่ 8 ของอาร์กิวเมนต์ OrderSend (ตรวจสอบโดยค้นหาด้วย OrderSend)
  • อักขระที่เป็นตัวอักษรและตัวเลขคละกันแบบครึ่งความกว้างสูงสุด 31 ตัว
Example: In the case of product ID 12345, product name GogoJungleEA
int ticket = OrderSend( ①, ②, ③, ④, ⑤, ⑥, ⑦, "12345:GogoJungle_EA", ⑨, ⑩, ⑪);

9. ลิขสิทธิ์

9-1 การยืนยันการถอดรหัส

  • ไม่ถอดรหัสรหัส
[Example
double Gda_280[30];
int G_digits_192=0;
double G_point_196=0.0;
int Gi_204;
double Gd_208;
double Gd_216; double
double Gd_224; double Gd_224;.
  • แม้ว่ารหัสจะถูกเข้ารหัส แต่ก็ยากที่จะถอดรหัส ดังนั้นโปรดตรวจสอบปัญหาลิขสิทธิ์
[Example
int 2516972921474835825095 ;
int 919926175214748358129332 ;
int OnInit()
{
    158651616521474836452710 = 945331452214748360523750 (); int
    1821361779214748361111350 ( 158651616521474836452710 );
  • ไม่มีคำอธิบายที่เกี่ยวข้องกับใบอนุญาต
[Example.
//#include <MT4params.mqh>
//#include <MT4License_1.mqh>
//int group_no = 11,group,a1=1; //group number 0:not used
//bool PC_Check = true; // true: do PC binding false: don't do it
//datetime PrevTime;
//string ServerURL0 = "http://reapseven.xsrv.jp/license";
//string ServerURL = "http://fxea.xsrv.jp/license"; //server URL
//string ServerURL2 = "http://fxea.xsrv.jp/license"; //string
//int stp=-1;
//#import "shell32.dll"
//int ShellExecuteW(int hWnd, int lpVerb, string lpFile, string lpParameters, string lpDirectory, int nCmdShow);
//#import
//string DataPath = TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\Libraries";

9-2 การยืนยันการละเมิดข้อกำหนดในการให้บริการ

  • อย่าอัปโหลดแหล่งที่มาที่คล้ายกันด้วยหลายบัญชี (การขายด้วยหลายบัญชีเป็นการละเมิดข้อกำหนดในการให้บริการ)

10.รายการตรวจสอบใน MT5

10-1. การติดต่อกับบริษัทหลักทรัพย์

  • จำเป็นต้องได้มูลค่าที่ตรงกับ 1 หรือ 2 ที่บริษัทหลักทรัพย์มีอยู่ (ค้นหาโดยพิมพ์_filling และยืนยัน)

ถ้า 1: ORDER_FILLING_FOK *ค่าเริ่มต้น
สำหรับ 2: ORDER_FILLING_IOC

[Example
int FillingMode=(int)SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE);
if(FillingMode == 2){
      request.type_filling = ORDER_FILLING_IOC;
}

10-2.การคำนวณจำนวนตำแหน่งที่เปิด

  • จำนวนตำแหน่งจะนับโดยการตัดสินคู่สกุลเงินและตัวเลขมหัศจรรย์ (ค้นหาด้วย PositionsTotal เพื่อยืนยัน)
[Example
   int pos = 0;.
   int posTotal=PositionsTotal();
   for( int posIndex=0; posIndex<posTotal; posIndex++ )
     {
      const ulong ticket=PositionGetTicket(posIndex);
      if(PositionSelectByTicket(ticket) &&
         PositionGetString(POSITION_SYMBOL)==_Symbol &&
         PositionGetInteger(POSITION_MAGIC)==Magic_Number)
        {
            pos++; }
        }
     }
  }

10-3.เอนทรี่

  • ต้องสั่งซื้อด้วยหมายเลขเวทมนตร์โดยพลการของผู้ใช้ ณ เวลาที่เข้า
  • คู่สกุลเงิน ณ เวลาที่เข้าจะต้องสั่งซื้อด้วยมูลค่าที่นายหน้าพิจารณา
  • ต้องตั้งค่า SL/TP หากไม่มีลอจิกคำสั่งการชำระบัญชี
[Example
input int Magic_Number;
MqlTradeRequest request;
MqlTradeResult result;

request.action = TRADE_ACTION_DEAL;
request.magic = Magic_Number;
request.symbol = _Symbol;
request.volume = 0.1;
request.sl = stoploss;
request.tp = takeprofit;
request.position = 0;

OrderSend(request,result);

10-4.การชำระเงิน

  • ตรวจสอบให้แน่ใจว่าปิดตำแหน่งที่ถูกต้องแล้ว (อย่าปิดตำแหน่งที่ได้มาของ EA อื่นโดยไม่ตั้งใจ)
    สั่งจ่ายตามหมายเลขตั๋ว
  • ความล้มเหลวของคำสั่งระงับบัญชีจะถูกนำมาพิจารณาด้วย
  • พิจารณาการเริ่มต้นของตัวแปรทั่วโลก
[Example
   int posTotal=PositionsTotal();
   for( int posIndex=0; posIndex<posTotal; posIndex++ )
     {
      const ulong ticket=PositionGetTicket(posIndex);
      if(PositionSelectByTicket(ticket) &&
         PositionGetString(POSITION_SYMBOL)==_Symbol &&
         PositionGetInteger(POSITION_MAGIC)==Magic_Number)
        {
           MqlTradeRequest request request; MqlTradeResult result
           MqlTradeResult result;

           request.action = TRADE_ACTION_DEAL;
           request.magic = Magic_Number;
           request.symbol = _Symbol;
           request.volume = 0.1;
           request.sl = 0;
           request.tp = 0;
           request.position = ticket;

           OrderSend(request,result);
        }
     }
  }

สรุปแล้ว

Gogojan ดำเนินการตรวจสอบแหล่งที่มาข้างต้นสำหรับ EA ทั้งหมด
หากคุณมีปัญหาในการดำเนินงานหรือข้อมูลใหม่ โปรดแจ้งให้เราทราบ

เราจะอัปเดตรายการตรวจสอบเป็นครั้งคราวตามเนื้อหาที่รายงาน

เราหวังเป็นอย่างยิ่งว่าจะได้จัดแสดง EA ที่ยอดเยี่ยมของคุณ

コメント

関連トピックス

検索結果がありません。

ノーコードで誰でも簡単EA開発!MQL言語学習にも使える! | GogoJungle

注目トピックス

検索結果がありません。