ผู้เขียนจริง:
EarnForex
ถ้าคุณเป็นเทรดเดอร์มือใหม่และกำลังมองหาเครื่องมือที่ช่วยให้การวิเคราะห์ตลาดของคุณง่ายขึ้น อินดิเคเตอร์ BeginnerAlert อาจเป็นคำตอบที่คุณต้องการ! อินดิเคเตอร์นี้จะแสดงจุดสูงสุดและต่ำสุดของแนวโน้ม (extremums) ซึ่งสามารถใช้เป็นจุดสนับสนุน (support) และต้านทาน (resistance) ได้ มันจะช่วยให้คุณเห็นช่องทางของแนวโน้มปัจจุบันได้อย่างชัดเจน นอกจากนี้ยังมีฟีเจอร์แจ้งเตือนที่ส่งผ่านอีเมลและการแจ้งเตือนไปยังมือถืออีกด้วย
อินดิเคเตอร์นี้มีความเรียบง่าย โดยใช้ช่วงเวลาที่กำหนดในการหาจุดสูงสุดและต่ำสุด และทำเครื่องหมายด้วยจุดต่างๆ
เราได้ทำการปรับปรุงโค้ดของอินดิเคเตอร์นี้เพื่อเพิ่มฟังก์ชันแจ้งเตือน อีเมล และการแจ้งเตือนผ่านมือถือ:
- เพิ่มพารามิเตอร์ใหม่ในโค้ดเพื่อเพิ่มฟังก์ชันการแจ้งเตือน:
input uint NumberofBar=1;//จำนวนบาร์สำหรับสัญญาณ input bool SoundON=true; //เปิดการแจ้งเตือน input uint NumberofAlerts=2;//จำนวนการแจ้งเตือน input bool EMailON=false; //เปิดการส่งสัญญาณทางอีเมล input bool PushON=false; //เปิดการส่งสัญญาณไปยังมือถือ
- เพิ่มฟังก์ชันใหม่สามฟังก์ชันที่ส่วนท้ายของโค้ดอินดิเคเตอร์:
//+------------------------------------------------------------------+ //| ฟังก์ชัน Buy signal | //+------------------------------------------------------------------+ void BuySignal(string SignalSirname, // ชื่อของอินดิเคเตอร์สำหรับอีเมลและการแจ้งเตือน double &BuyArrow[], // บัฟเฟอร์ของอินดิเคเตอร์ที่มีสัญญาณซื้อ const int Rates_total, // จำนวนบาร์ที่ปัจจุบัน const int Prev_calculated, // จำนวนบาร์ในแท่งก่อนหน้า const double &Close[], // ราคาปิด const int &Spread[]) // spread { //--- static uint counter=0; if(Rates_total!=Prev_calculated) counter=0; bool BuySignal=false; bool SeriesTest=ArrayGetAsSeries(BuyArrow); int index; if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) BuySignal=true; if(BuySignal && counter<=NumberofAlerts) { counter++; MqlDateTime tm; TimeToStruct(TimeCurrent(),tm); string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min); SeriesTest=ArrayGetAsSeries(Close); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; double Ask=Close[index]; double Bid=Close[index]; SeriesTest=ArrayGetAsSeries(Spread); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; Bid+=Spread[index]; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); if(SoundON) Alert("BUY signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod); if(EMailON) SendMail(SignalSirname+": BUY signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); if(PushON) SendNotification(SignalSirname+": BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); } //--- } //+------------------------------------------------------------------+ //| ฟังก์ชัน Sell signal | //+------------------------------------------------------------------+ void SellSignal(string SignalSirname, // ชื่อของอินดิเคเตอร์สำหรับอีเมลและการแจ้งเตือน double &SellArrow[], // บัฟเฟอร์ของอินดิเคเตอร์ที่มีสัญญาณขาย const int Rates_total, // จำนวนบาร์ที่ปัจจุบัน const int Prev_calculated, // จำนวนบาร์ในแท่งก่อนหน้า const double &Close[], // ราคาปิด const int &Spread[]) // spread { //--- static uint counter=0; if(Rates_total!=Prev_calculated) counter=0; bool SellSignal=false; bool SeriesTest=ArrayGetAsSeries(SellArrow); int index; if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) SellSignal=true; if(SellSignal && counter<=NumberofAlerts) { counter++; MqlDateTime tm; TimeToStruct(TimeCurrent(),tm); string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min); SeriesTest=ArrayGetAsSeries(Close); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; double Ask=Close[index]; double Bid=Close[index]; SeriesTest=ArrayGetAsSeries(Spread); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; Bid+=Spread[index]; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); if(SoundON) Alert("SELL signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod); if(EMailON) SendMail(SignalSirname+": SELL signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); if(PushON) SendNotification(SignalSirname+": SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); } //--- } //+------------------------------------------------------------------+ //| รับช่วงเวลาเป็นสตริง | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- }
- เพิ่มการเรียกใช้งานฟังก์ชัน BuySignal() และ SellSignal() หลังจากการคำนวณอินดิเคเตอร์ในบล็อก OnCalculate():
//--- BuySignal("BeginnerAlert",BuyBuffer,rates_total,prev_calculated,Close,spread); SellSignal("BeginnerAlert",SellBuffer,rates_total,prev_calculated,Close,spread); //---
โดยที่ BuyBuffer และ SellBuffer คือชื่อของบัฟเฟอร์อินดิเคเตอร์ที่ใช้เก็บสัญญาณซื้อและขาย ค่าที่ว่างในบัฟเฟอร์อินดิเคเตอร์จะต้องเป็นศูนย์หรือ EMPTY_VALUE
สำหรับการเรียกใช้ฟังก์ชัน BuySignal() และ SellSignal() จะต้องใช้เพียงครั้งเดียวในบล็อก OnCalculate() ของโค้ดอินดิเคเตอร์นี้
อินดิเคเตอร์นี้ถูกเขียนขึ้นใน MQL4 และถูกเผยแพร่ครั้งแรกใน Code Base เมื่อวันที่ 03.09.2008

Fig1. อินดิเคเตอร์ BeginnerAlert บนกราฟ

Fig.2. อินดิเคเตอร์ BeginnerAlert สร้างการแจ้งเตือน
โพสต์ที่เกี่ยวข้อง
- เครื่องมือ Open Range Breakout สำหรับ MetaTrader 5
- Volume Profile + Range v6.0: เครื่องมือวิเคราะห์การซื้อขายใน MetaTrader 5
- Unity Pro: อินดิเคเตอร์ใหม่สำหรับ MetaTrader 5 ที่นักเทรดห้ามพลาด
- การใช้ Cycle Period ใน MetaTrader 5 สำหรับนักเทรด
- Volume Profile + Range v6.0: อินดิเคเตอร์สำหรับ MetaTrader 5 เพื่อการเทรดที่แม่นยำ