ผู้เขียนจริง: Ramdass - การแปลงข้อมูลเท่านั้น
เครื่องมือ BykovTrend เป็นสัญญาณเซมาฟอร์ที่มีฟีเจอร์แจ้งเตือน รวมถึงการส่งอีเมลและการแจ้งเตือนผ่านมือถือ
การเปลี่ยนแปลงในโค้ดของตัวชี้วัดนี้มีจุดประสงค์เพื่อการใช้งานแจ้งเตือน อีเมล และการส่งแจ้งเตือนผ่านมือถือ:
- เพิ่มพารามิเตอร์การตั้งค่าใหม่
inputuint NumberofBar=1;//จำนวนแท่งสำหรับสัญญาณinputbool SoundON=true; //เปิดใช้งานการแจ้งเตือนinputuint NumberofAlerts=2;//จำนวนการแจ้งเตือนinputbool EMailON=false; //เปิดใช้งานการส่งสัญญาณทางอีเมลinputbool PushON=false; //เปิดใช้งานการส่งสัญญาณไปยังมือถือ
- เพิ่มฟังก์ชันใหม่ 3 ฟังก์ชัน: BuySignal(), SellSignal() และ GetStringTimeframe()
//+------------------------------------------------------------------+//| ฟังก์ชันสัญญาณซื้อ |//+------------------------------------------------------------------+void BuySignal(string SignalSirname, //ข้อความชื่อของตัวชี้วัดสำหรับอีเมลและข้อความแจ้งเตือน double &BuyArrow[], //บัฟเฟอร์ข้อมูลสำหรับสัญญาณซื้อ constint Rates_total, //จำนวนแท่งปัจจุบัน constint Prev_calculated, //จำนวนแท่งในแท่งก่อนหน้า constdouble &Close[], //ราคาปิด constint &Spread[]) //สเปรด { //--- staticuint 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; doubleAsk=Close[index]; doubleBid=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); } //--- } //+------------------------------------------------------------------+//| ฟังก์ชันสัญญาณขาย |//+------------------------------------------------------------------+void SellSignal(string SignalSirname, //ข้อความชื่อของตัวชี้วัดสำหรับอีเมลและข้อความแจ้งเตือน double &SellArrow[], //บัฟเฟอร์ข้อมูลสำหรับสัญญาณขาย constint Rates_total, //จำนวนแท่งปัจจุบัน constint Prev_calculated, //จำนวนแท่งในแท่งก่อนหน้า constdouble &Close[], //ราคาปิด constint &Spread[]) //สเปรด { //--- staticuint 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; doubleAsk=Close[index]; doubleBid=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("BykovTrendAlert",BuyBuffer,rates_total,prev_calculated,close,spread); SellSignal("BykovTrendAlert",SellBuffer,rates_total,prev_calculated,close,spread); //---
โดยที่ BuyBuffer และ SellBuffer คือชื่อของบัฟเฟอร์ที่ใช้สำหรับเก็บสัญญาณซื้อและขาย ค่าที่ว่างในบัฟเฟอร์จะต้องเป็นศูนย์หรือ EMPTY_VALUE
เดิมทีตัวชี้วัดนี้ถูกพัฒนาใน MQL4 และเผยแพร่ใน Code Base เมื่อวันที่ 28.09.2007

Fig1. ตัวชี้วัด BykovTrendAlert บนกราฟ
Fig.2. ตัวชี้วัด BykovTrendAlert กำลังสร้างการแจ้งเตือน


ความคิดเห็น 0