HomeCoding-Programingเขียน EA ส่งแจ้งเตือนเข้า Line | Send Line Notify in MT4/MT5 EA

เขียน EA ส่งแจ้งเตือนเข้า Line | Send Line Notify in MT4/MT5 EA

-

==== Chapters ====
00:00 เกริ่น
01:15 ฟังค์ชั่น LineNotify ใน MQL4 script
02:44 การขอ Access Token จาก Line notify
04:15 ตัวอย่างการเรียกใช้ฟังค์ชั่น LineNotify ใน EA
06:43 ฟังค์ชั่น LineNotify นี้ทำงานยังไง?
07:53 อธิบาย MQL4 webrequest เบื้องต้น
09:29 การส่ง request ตาม Line API document
11:11 เตรียม request header และ ข้อมูลที่จะส่งไป server
12:52 ข้อมูลครบก็ส่ง webrequest ได้เลย
14:03 ปรับแต่งเพิ่มเติม – ส่ง Line Sticker
15:39 ปรับแต่งเพิ่มเติม – ส่ง รูปภาพบนเว็บ
17:37 การขึ้นบรรทัดใหม่ / การใส่ emoji
19:12 สรุป

//+------------------------------------------------------------------+
//|                                                   LineNotify.mq4 |
//|                                Copyright 2022, RookieTraders.com |
//|                                    https://www.RookieTraders.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, RookieTraders.com"
#property link      "https://www.RookieTraders.com"
#property version   "1.00"
#property strict

string Line_Token = "---PutYourTokenHere--" ;

//--- Don't forget to put URL https://notify-api.line.me/api/notify to MT4/MT5 Allow webrequest listed url

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   string LineMessage = "Put Your Message Here" ;
   LineNotify(Line_Token,LineMessage);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void LineNotify(string token,string Message)
  {
   int ErrorCode;
   string RequestMethod = "POST";
   string Line_Notify_URL = "https://notify-api.line.me/api/notify"; // put this url to MT4/MT5 Allow webrequest listed url
   string headers,  messagestring ;
   char msgData[],result[];
   string result_headers ;
   int timeout = 10000 ;
   
   //---- Create Header -----
   headers="Content-Type: application/x-www-form-urlencoded\r\n"  ;
   headers+="Authorization: Bearer "+token+"\r\n";
   
   //------ Create Message Char Array---
   messagestring = "message="+Message ;
   StringToCharArray(messagestring,msgData,0,WHOLE_ARRAY,CP_UTF8);
   ArrayResize(msgData,ArraySize(msgData)-1);
   
   //--- Send HTTP Request ------- 
   int res = WebRequest(RequestMethod, Line_Notify_URL, headers, timeout, msgData, result, result_headers);
   if(res==-1)
     {
      ErrorCode = GetLastError();
      Print("WebRequest Error:",ErrorCode) ;
      if(ErrorCode==4060)
        {
         Alert("Add the address '"+Line_Notify_URL+"' in the list of allowed URLs on tab 'Expert Advisors' ") ;
        }
     }
   else
      Print("Server response: ", CharArrayToString(result)) ;
     
  }


1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

LATEST POSTS

เขียนโค๊ด MQL4 ปิดออเดอร์ทั้งหมดใน MT4 | Close All Orders MQL4 Coding

https://youtu.be/b2P7PW6lqP0 ในคลิปนี้เรามาดูวิธีเขียน code script mql4 ที่จะช่วยเราปิดออเดอร์ทั้งหมดใน MT4บางคนอาจจะเคยเขียนแล้ว ทั้งๆที่ไม่มี error อะไรเลย แต่ก็ปิดออเดอร์ได้ไม่หมด เพราะอะไรยังไงลองดูเป็นแนวทางเพิ่มเติมละกันนะครับ เพื่อนๆสามารถนำ code นี้ไปปรับแต่งสร้างเป็นฟังค์ชั่นที่ใช้ภายใน EA ของเพื่อนๆได้นะครับ ลิงค์เว็บที่ได้กล่าวถึงในคลิป https://www.mql5.com/en/forum/139654 สำหรับเพื่อนๆที่เพิ่งได้ดูคลิปนี้เป็นคลิปแรกแนะนำดูคลิปเก่าๆที่ผมได้ปูพื้นฐานเกี่ยวกับการเขียน EA ด้วย MQL4 ตาม Playlist ด้านล่างนี้ได้นะครับhttps://www.youtube.com/playlist?list=PLC5FDftkfAqyeg6ipIo0Hqm7NqpT7EkxHดูแล้วไม่เข้าใจยังไง comment มาพูดคุยกันได้นะครับ=======...

สอนเขียน MQL4 Indicator หาราคาต้นทุนเฉลี่ยเพื่อ Breakeven

ในคลิปนี้ เรามาฝึกการเขียน Code MQL4 กันโดยจะมาลองสร้าง MT4 indicator ที่ช่วยแสดงราคาต้นทุนเฉลี่ยรวมของทุกออร์เดอร์ฝั่ง buy หรือ ฝั่ง sell ในคู่เงินนั้นๆกันนะครับ https://www.youtube.com/watch?v=HVbAhl7m4_4 ราคาต้นทุนเฉลี่ยรวมนี้ จะเป็นระดับราคาที่ทำให้ Order ฝั่งนั้นๆ ( buy หรือ sell) สามารถปิดออร์เดอร์แล้วจะไม่กำไรหรือขาดทุน (Breakeven price) เมื่อเรารู้ราคา Breakeven...

สอนเขียน EA MQL4 เทรดด้วย 3 EMA + Fractal Trading System

https://youtu.be/5EI9xOs-3_Y ===== Chapters ===== 00:00 เกริ่น01:32 เงื่อนไขระบบเทรด 3 EMA+Fractal04:01 ตัวอย่างการทำงานของ EA07:00 Flowchart การทำงาน EA09:50 Mql4 Code : ส่วนของการรับค่า input11:17 Mql4 Code : อธิบายการทำงานหลักใน OnTick13:22 เขียน function เช็ค...

ATR Stop Loss – วาง SL ตามค่าความผันผวนของราคา | เขียน MQL4 Script ส่ง Order พร้อมวาง SL ตามค่า Volatility จาก ATR

https://youtu.be/s6qfIc8UFEk สำหรับเพื่อนๆที่เพิ่งได้ดูคลิปนี้เป็นคลิปแรก แนะนำดูคลิปเก่าๆที่ผมได้ปูพื้นฐานเกี่ยวกับ การเขียน EA ด้วย MQL4 ตาม Playlist ด้านล่างนี้ได้นะครับhttps://www.youtube.com/playlist?list=PLC5FDftkfAqyeg6ipIo0Hqm7NqpT7EkxHดูแล้วไม่เข้าใจยังไง comment มาพูดคุยกันได้นะครับ 00:00 เกริ่น01:05 ข้อจำกัด Fixed Stop Loss02:40 ตัวอย่างแนวคิดวาง SL ตามค่าความผันผวนจาก ATR05:14 ตัวอย่างการใช้งานโปรแกรม Script ที่จะลองเขียนกัน06:20 เริ่มเขียน Code...

Follow us

0FansLike
9,070SubscribersSubscribe

Most Popular