อ้างจาก: forcebewithyou ที่ 29, มีนาคม 2020, 03:54:25 PM
ลองเขียนให้มัน alert เฉพาะ new bar ดูครับ
คำสั่ง alert ก็ทำเป็นฟั่งชั่น alert ขึ้นมาแล้วเรียกฟังชั่นออกมาใช้ แล้วในฟังชั่น ก็ใส่ code ทำงานเฉพาะ new bar เข้าไปครับ
ลองดู code new bar ได้ใน mql5.com ดูครับ มีหลายแบบลองก็อปมาใช้สักแบบ
หรือใช้เทนนิคอีเอ บางทีก็ใช้กันคือ ivolume มีค่าไม่เกิน 1 เป็นต้น (คือ ทำงานที่ tick ที่ 1)
ลองทดสอบดูครับ
ไอเดียอื่นๆ ลองตั้งค่า alerted สำหรับบันทึกว่า เตือนไปแล้วไว้ แล้วพอเตือนครั้งแรก ก็จะเซ็ตให้มันเป็นเตือนแล้ว พอซ้ำก็จะไม่ทำงาน แต่ต้องไปตั้งค่าให้มันเป็น 0 อีกทีตอนไม่มีออกมา ต้องลองไม่รู้จะ work หรือเปล่านะ
ผมพอจะแก้โค้ดได้ แต่ผมไม่รู้จะเขียนฟังก์ชั่นยังไง รบกวนช่วยเขียนให้ดูได้ไหมครับ
โค้ดด้านล่างนี้เป็นโค้ดของ Indicator ที่ผมนำค่ามาใช้
string trend;
string comment;
color coltrend;
color colcomment;
double xt, xc;
if(StrToDouble(Trend_UP) >= TrendStrongLevel) { trend = "UP"; coltrend = Lime; xt = 935; comment = "[strong]"; xc = 921; colcomment = Lime; /* if (alert == true) { Alert(TimeToStr(TimeCurrent(),TIME_SECONDS)," Trend UP > "TrendStrongLevel"% on ",Symbol()," ", Bid); PlaySound("tick.wav"); } */ }
else if(StrToDouble(Trend_UP) < TrendStrongLevel && StrToDouble(Trend_UP) >= 50) { trend = "UP"; coltrend = Lime; xt = 935; comment = "[weak]"; xc = 924; colcomment = Red; }
else if(StrToDouble(Trend_DOWN) >= TrendStrongLevel) { trend = "DOWN"; coltrend = Red; xt = 918; comment = "[strong]"; xc = 921; colcomment = Red; /* if (alert == true) { Alert(TimeToStr(TimeCurrent(),TIME_SECONDS)," Trend DOWN > "TrendStrongLevel"% on ",Symbol()," ", Bid); PlaySound("tick.wav"); } */ }
else if(StrToDouble(Trend_DOWN) < TrendStrongLevel && StrToDouble(Trend_DOWN) > 50) { trend = "DOWN"; coltrend = Red; xt = 918; comment = "[weak]"; xc = 924; colcomment = Red; }