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

ขอคำเเนะนำคับเรื่องการเขียน EA

  • 5 replies
  • 2,670 views
ขอคำเเนะนำคับเรื่องการเขียน EA
« เมื่อ: 22, ธันวาคม 2018, 09:48:12 PM »
เบื้องต้นผมมีต้นเเบบ EA จาก indicator Super signal V3D  ผมต้องการเพียงรันโดย EA ไม่ทำการเปิด order เเต่อย่างไร ต้องการเเค่เพียงให้ EA เเจ้งเตือนผ่าน Line ว่าถึงจุดเข้าออเดอร์เเล้ว  เเต่ปัญหาติดอยู่ว่า ทำให้ส่งข้อความผ่านไลน์ได้เเต่ ไม่สามารถส่งค่าของ EA ออกไปได้ มีเเค่ค่าของตัวเเปล True fualt T T ขอคำเเนะนำหน่อยคับผม

*

iRuler

  • 1,282
Re: ขอคำเเนะนำคับเรื่องการเขียน EA
« ตอบกลับ #1 เมื่อ: 22, ธันวาคม 2018, 10:56:36 PM »
ไม่มีโค้ด แนะนำไม่ถูกน่ะครับ (TH)**

Re: ขอคำเเนะนำคับเรื่องการเขียน EA
« ตอบกลับ #2 เมื่อ: 23, ธันวาคม 2018, 03:17:13 PM »
อ้างจาก: iRuler ที่ 22, ธันวาคม  2018, 10:56:36 PM
ไม่มีโค้ด แนะนำไม่ถูกน่ะครับ (TH)**


#property copyright "gooo"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict


extern int  dist2           = 28;
extern int  dist1           = 14;
extern bool alertsOn        = true;
extern bool alertsOnCurrent = true;
extern bool alertsMessage   = true;
extern bool alertsSound     = true;
extern bool alertsEmail     = false;


double b1[];
double b2[];
double b3[];
double b4[];
     int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit,hhb,llb,hhb1,llb1;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
           limit=MathMax(limit,dist1);
           limit=MathMax(limit,dist2);

   //
   //
   //
   //
   //

   for (i=limit;i>=0;i--)
      {
         hhb1 = Highest(NULL,0,MODE_HIGH,dist1,i-dist1/2);
         llb1 = Lowest(NULL,0,MODE_LOW,dist1,i-dist1/2);
         hhb  = Highest(NULL,0,MODE_HIGH,dist2,i-dist2/2);
         llb  = Lowest(NULL,0,MODE_LOW,dist2,i-dist2/2);

            b1 = EMPTY_VALUE;
            b2 = EMPTY_VALUE;
            b3 = EMPTY_VALUE;
            b4 = EMPTY_VALUE;
     
         double tr = iATR(NULL,0,50,i);
         if (i==hhb)  b1=High[hhb] +tr;
         if (i==llb)  b2=Low[llb]  -tr;
         if (i==hhb1) b3=High[hhb1]+tr/2;
         if (i==llb1) b4=Low[llb1] -tr/2;
      }
     
   //
   //
   //
   //
   //
   
   if (alertsOn)
      {
         int forBar = 1;
            if (alertsOnCurrent) forBar = 0;
            if (b1[forBar] != EMPTY_VALUE && b3[forBar] != EMPTY_VALUE) doAlert("strong sell");
            if (b1[forBar] != EMPTY_VALUE && b3[forBar] == EMPTY_VALUE) doAlert("sell");
            if (b1[forBar] == EMPTY_VALUE && b3[forBar] != EMPTY_VALUE) doAlert("minor sell or exit buy");
            if (b2[forBar] != EMPTY_VALUE && b4[forBar] != EMPTY_VALUE) doAlert("strong buy");
            if (b2[forBar] != EMPTY_VALUE && b4[forBar] == EMPTY_VALUE) doAlert("buy");
            if (b2[forBar] == EMPTY_VALUE && b4[forBar] != EMPTY_VALUE) doAlert("minor buy or exit sell");
      }
  return(0);
}

//
//
//
//
//

void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   string TimePeriod;
   
   if (Period()== 15)      TimePeriod = "15 MIN";
   if (Period()== 30)      TimePeriod = "30 MIN";
   if (Period()== 60)      TimePeriod = "1 HR";
   if (Period()== 240)     TimePeriod = "4 HR";
   if (Period()== 1440)    TimePeriod = "DAILY";
   if (Period()== 10080)   TimePeriod = "WEEKLY";
   if (Period()== 43200)   TimePeriod = "MONTHLY";

      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];

          //
          //
          //
          //
          //

          message =  StringConcatenate(Symbol()," at ", TimePeriod, " Super signal : ",doWhat);
             if (alertsMessage) Alert(message);
           
      }
}
input string message="";
  extern string extoken = "iLBBeCNLhMhX0nQ0fGkpFAKN53kQuHN9AN1oEgCq1fd" ;
void OnTick(){

LineNotify(extoken,"message");

}
void LineNotify(string token,string Massage){
string headers;
char post[], result[];

headers="Authorization: Bearer "+token+"\r\n";
headers+="Content-Type: application/x-www-form-urlencoded\r\n";

ArrayResize(post,StringToCharArray("message="+message,post,0,WHOLE_ARRAY,CP_UTF8)-1);

int res = WebRequest("POST", "https://notify-api.line.me/api/notify", headers, 10000, post, result, headers);

Print("Status code: " , res, ", error: ", GetLastError());
Print("Server response: ", CharArrayToString(result));
}

มือใหม่คับผมขอความกรุณาด้วย

Re: ขอคำเเนะนำคับเรื่องการเขียน EA
« ตอบกลับ #3 เมื่อ: 23, ธันวาคม 2018, 06:18:40 PM »
ผมเคยทดสอบ code ของท่านนี้ใช้งานได้นะครับ

https://medium.com/@peeradonmekup/มาเขียน-mql4-ส่ง-line-notify-กันเถอะ-15c573a33c9


*

iRuler

  • 1,282
Re: ขอคำเเนะนำคับเรื่องการเขียน EA
« ตอบกลับ #4 เมื่อ: 23, ธันวาคม 2018, 09:11:23 PM »
อ้างจาก: James Harutape ที่ 23, ธันวาคม  2018, 03:17:13 PM
อ้างจาก: iRuler ที่ 22, ธันวาคม  2018, 10:56:36 PM
ไม่มีโค้ด แนะนำไม่ถูกน่ะครับ (TH)**

void LineNotify(string token,string Massage){
string headers;
char post[], result[];

headers="Authorization: Bearer "+token+"\r\n";
headers+="Content-Type: application/x-www-form-urlencoded\r\n";

ArrayResize(post,StringToCharArray("message="+message,post,0,WHOLE_ARRAY,CP_UTF8)-1);

int res = WebRequest("POST", "https://notify-api.line.me/api/notify", headers, 10000, post, result, headers);

Print("Status code: " , res, ", error: ", GetLastError());
Print("Server response: ", CharArrayToString(result));
}



ง่ายมาก แค่เพิ่มส่วน LineNotify เข้าไปเองครับ

(TH)**

Re: ขอคำเเนะนำคับเรื่องการเขียน EA
« ตอบกลับ #5 เมื่อ: 29, มิถุนายน 2019, 06:52:01 PM »

อินดิเคเตอร์ลองใช้ตัวนี้ดูครับ มีคนไทยทำแจกครับ



https://drive.google.com/drive/folders/1OF1kGb8RJ6W4xgIwONv867PjiQSenYQf?usp=sharing


indicator ต้องใช้เป็น DLL ครับ