ผู้เขียน:
พอล สตริงเกอร์
ตัวชี้วัดนี้ช่วยให้คุณสามารถระบุรูปแบบ Harami และยังมีฟังก์ชันแจ้งเตือนผ่านอีเมลและการแจ้งเตือนทางมือถือ
ในตัวชี้วัดนี้ได้มีการปรับปรุงโค้ดเพื่อให้สามารถส่งแจ้งเตือน, ส่งอีเมล และการแจ้งเตือนทางมือถือได้:
- เพิ่มพารามิเตอร์ใหม่ในโค้ดตัวชี้วัด
input uint NumberofBar=1;//จำนวนบาร์สำหรับสัญญาณ input bool SoundON=true; //เปิดใช้งานการแจ้งเตือน input uint NumberofAlerts=2;//จำนวนการแจ้งเตือน input bool EMailON=false; //เปิดใช้งานการส่งสัญญาณทางอีเมล input bool PushON=false; //เปิดใช้งานการส่งสัญญาณไปยังอุปกรณ์มือถือ
- เพิ่มฟังก์ชันใหม่สามฟังก์ชันลงในโค้ดตัวชี้วัด: BuySignal(), SellSignal() และ GetStringTimeframe()
//+------------------------------------------------------------------+ //| ฟังก์ชันสัญญาณซื้อ | //+------------------------------------------------------------------+ void BuySignal(string SignalSirname, // ชื่อของตัวชี้วัดสำหรับข้อความอีเมลและการแจ้งเตือน double &BuyArrow[], // ตัวบัฟเฟอร์สำหรับสัญญาณซื้อ const int Rates_total, // จำนวนบาร์ในปัจจุบัน const int Prev_calculated, // จำนวนบาร์จากการคำนวณก่อนหน้า const double &Close[], // ราคาปิด const int &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]*_Point; 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); } //--- } //+------------------------------------------------------------------+ //| ฟังก์ชันสัญญาณขาย | //+------------------------------------------------------------------+ void SellSignal(string SignalSirname, // ชื่อของตัวชี้วัดสำหรับข้อความอีเมลและการแจ้งเตือน double &SellArrow[], // ตัวบัฟเฟอร์สำหรับสัญญาณขาย const int Rates_total, // จำนวนบาร์ในปัจจุบัน const int Prev_calculated, // จำนวนบาร์จากการคำนวณก่อนหน้า const double &Close[], // ราคาปิด const int &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]*_Point; 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("Harami_Alert",BuyBuffer,rates_total,prev_calculated,close,spread); SellSignal("Harami_Alert",SellBuffer,rates_total,prev_calculated,close,spread); //---
ที่นี่ BuyBuffer และ SellBuffer เป็นชื่อของบัฟเฟอร์ตัวชี้วัดสำหรับเก็บสัญญาณซื้อและขาย โดยค่าที่ว่างเปล่าในบัฟเฟอร์ตัวชี้วัดควรตั้งเป็น 0 หรือ EMPTY_VALUE
คาดว่า การเรียกใช้ฟังก์ชัน BuySignal() และ SellSignal() จะต้องใช้เพียงครั้งเดียวในบล็อก OnCalculate() ของโค้ดตัวชี้วัด
โดยตัวชี้วัดนี้ถูกเขียนครั้งแรกด้วย MQL4 และเผยแพร่ครั้งแรกใน Code Base เมื่อวันที่ 14 มิถุนายน 2016

Fig. 1. Harami_Alert indicator on the chart
Fig. 2. Harami_Alert. Generating alerts
โพสต์ที่เกี่ยวข้อง
- เครื่องมือ Open Range Breakout สำหรับ MetaTrader 5
- เครื่องมือ Flexible Momentum สำหรับ MT5 - ช่วยเทรดได้แม่นยำขึ้น
- ID Lite Info MA – ตัวช่วยวิเคราะห์ Moving Average สำหรับ MetaTrader 5
- ปรับ MACD ให้แม่นยำยิ่งขึ้นด้วยการแจ้งเตือนสัญญาณแบบเรียลไทม์บนมือถือ
- Volume Profile + Range v6.0: เครื่องมือวิเคราะห์การซื้อขายใน MetaTrader 5
