กองทุน SPDR GOLD SHARES
ถือทองก่อนหน้า
ถือทองล่าสุด
0.00
*หน่วยตัน / ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ
สถิติกองทุน SPDR
ราคาทองคำแท่ง 96.5%
ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ
ครั้งที่
ราคาก่อนหน้า
ราคาล่าสุด
0
(หน่วย บาท*) / อัปเดตล่าสุดเมื่อวันที่ 13 ก.ค. 2566 เวลา 13:04 น.
สถิติราคาทองคำ ไทย

แปลง Copytrade จาก mt4 to mt5

  • 4 replies
  • 1,809 views
แปลง Copytrade จาก mt4 to mt5
« เมื่อ: 21, พฤศจิกายน 2021, 04:52:56 PM »
ท่าน admin ครับ ผมลองแปลงโค๊ด copy trade จาก mt4 มาเป็น mt5
มันก็อปปี้เทรดให้ปกติครับ
ปัญหาก็คือ
มันลบออร์เดอร์ออกให้ทันทีเลยครับ ผมคิดว่ามันน่าจะมาจากตอนเช็คออร์เดอร์ แล้วลบออร์เดอร์ออก
บรรทัดตามในภาพด้านล่างนี้

ท่าน admin ครับ ผมลองมาหลายวิธีทั้งวันแล้วครับ ที่ถูกต้องมันควรเป็นอย่างไรครับ ขอความรบกวนด้วยครับ

(TH)** (TH)** (TH)**

*

iRuler

  • 1,282
Re: แปลง Copytrade จาก mt4 to mt5
« ตอบกลับ #1 เมื่อ: 22, พฤศจิกายน 2021, 07:33:36 AM »
ต้องดู function InList() ด้วยครับว่า ทำงานอย่างไร

(TH)**

Re: แปลง Copytrade จาก mt4 to mt5
« ตอบกลับ #2 เมื่อ: 22, พฤศจิกายน 2021, 09:34:34 AM »
อ้างจาก: iRuler ที่ 22, พฤศจิกายน  2021, 07:33:36 AM
ต้องดู function InList() ด้วยครับว่า ทำงานอย่างไร

(TH)**

ผมได้แนบไฟล์ mq5 มาด้วยแล้วครับ ไม่รู้ว่ามันทำงานถูกต้องหรือเปล่าครับ

*

iRuler

  • 1,282
Re: แปลง Copytrade จาก mt4 to mt5
« ตอบกลับ #3 เมื่อ: 29, พฤศจิกายน 2021, 09:14:46 AM »
ลอง comment บันทัด 194-220 ออกแล้วลองดูว่า order ใน slave เปิดแล้วปิดอยู่ไหม
ถ้ายังปิดอยู่ต้องหาสาเหตุที่ส่วนอื่นแล้วครับ แต่ถ้าไม่ปิด แสดงว่าปัญหาอยู่ที่ส่วนนี้จริง ให้ลองเปลี่ยน code ของ loop for เป็นแบบนี้ดูครับ

โค๊ด [Select]
      //--- If deal was closed on master-account, close it on slave-accont
      for(int i=0; i<=PositionsTotal()-1; i++)
        {
         if(!m_position.SelectByIndex(i))
            continue;
         if(StringSubstr(m_position.Comment(),0,3)!="C4F")
            continue;

         Print("####### Debug Comment:",m_position.Comment());
         Print("Master ticket:",StringToInteger(StringSubstr(m_position.Comment(),StringLen("C4F"),-1)));
         if(InList(StringToInteger(StringSubstr(m_position.Comment(),StringLen("C4F"),-1)))==-1)
           {
            Print(StringSubstr(m_position.Comment(),StringLen("C4F"),-1),": NOT in list");
            if(m_position.PositionType()==0)
              {
               if(!Trade.PositionClose(m_position.Ticket()))
                  Print("Error Buy: ",GetLastError()," during closing the order.");
              }
            else
               if(m_position.PositionType()==1)
                 {
                  if(!Trade.PositionClose(m_position.Ticket()))
                     Print("Error Sell: ",GetLastError()," during closing the order.");
                 }
               else
                  if(m_position.PositionType()>1)
                    {
                     if(!Trade.PositionClose(m_position.Ticket()))
                        Print("Error pending: ",GetLastError()," during deleting the pending order.");
                    }
           }
         else
           {
            Print(StringSubstr(m_position.Comment(),StringLen("C4F"),-1),": in list");
           }
         Print("####### End Debug");
        }//End for(int i=0; i<=PositionsTotal()-1; i++)


แล้วลองดูข้อมูลที่มัน print ออกมาว่าถูกต้องหรือไม่

ขออภัยที่ตอบช้าครับ
(TH)**

Re: แปลง Copytrade จาก mt4 to mt5
« ตอบกลับ #4 เมื่อ: 04, มกราคม 2022, 11:33:47 AM »
ขอแนวทางหน่อยได้ไหมครับ กำลังพยายามทำอยู่เช่นกัน