How to make an EA in mq5 to trade only one hour before high impact news, and one hour after?
- Dose it posible to creat any function of "mql code" posting in this forum?
- How can I read the history file using kernell32 library in mql4 and mql5?
- How to make a trade copier EA? from mt4 to mt5
By coding the datetime filters.
by coding with xml from web and time filter
give some examples please
thank you you are very helpfull
//+------------------------------------------------------------------+ //| PinkEventDate.mq5 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" int minAfter,minBefore; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { datetime date1=last_pink_event_date(); datetime date2=next_pink_event_date(); string text=""; if(date1>0)text+="LastPinkEventDate = "+string(date1) +"\n"+"minAfter = "+(string)minAfter; else text += "\n"+"No 'LastPink Event' available."; if(date2>0) text+="\n"+"NextPinkEventDate = "+string(date2) +"\n"+"minBefore = "+(string)minBefore; else text += "\n"+"No 'NextPink Event' available."; MessageBox(text,"Information",0); } //+------------------------------------------------------------------+ datetime last_pink_event_date() { string name=""; long date=0; int total=ObjectsTotal(0)-1; for(int i=total; i>=0; i --) { name=ObjectName(0,i); if(ObjectGetInteger(0,name,OBJPROP_TYPE,0) !=OBJ_EVENT) continue; if(ObjectGetInteger(0,name,OBJPROP_COLOR,0) != clrPink) continue; Print(ObjectGetString(0,name,OBJPROP_TEXT,0)); date=(long)ObjectGetInteger(0,name,OBJPROP_TIME); minAfter=(int)(date -(long)TimeCurrent())/60; return(datetime)date; } return 0; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ datetime next_pink_event_date() { string name=""; long date=0; int total=ObjectsTotal(0)-1; for(int i=0; i<ObjectsTotal(0); i++) { name=ObjectName(0,i); if(ObjectGetInteger(0,name,OBJPROP_TYPE,0)==OBJ_EVENT) if(ObjectGetInteger(0,name,OBJPROP_COLOR,0)==clrPink) { date=(long)ObjectGetInteger(0,name,OBJPROP_TIME); if(date>TimeCurrent()) { minBefore=(int)(date -(long)TimeCurrent())/60; Print(minBefore); Print((string)ObjectGetInteger(0,name,OBJPROP_COLOR,0)); return(datetime)date; } } } return 0; } //+------------------------------------------------------------------+
I solve it my self,thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register