
- 2014.02.25
- www.mql5.com
The threads/posts
The articles
Documentation
I've already read all these.
the use of ontick function isn't working well in the tester because when the symbol the multi ea attached to is changed the results change also.
the ontimer function seems to be working but it's very slow in the tester when trying optimization.
so i found that the chart event and book event is going to work somehow but the examples available about it the complex or simple but not explained well
all the examples have a hex number that i don't understand how it check the ticks with.
so please give a simple code that explain how to deal with the event handling for checking ticks for other symbols.
hi my friend .
The best multi-currency strategy is to use currency correlation and lock profits and losses. In this case, the entry and exit of the market process does not need to know the market direction
EA:
string Symbol[]={"AUDUSD","EURUSD","GBPUSD","USDCHF","USDCAD","USDJPY"}; int handle[],size; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- long chartID=ChartID(); ArrayResize(handle,size=ArraySize(Symbol)); for(int i=0;i<size;i++) if((handle[i]=iCustom(Symbol[i],_Period,"OnTick",chartID,i))==INVALID_HANDLE) return(INIT_FAILED); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- for(int i=0;i<size;i++) IndicatorRelease(handle[i]); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick(const string &symbol,const double &price) { //--- Print(symbol," ",price); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if(id>=CHARTEVENT_CUSTOM) OnTick(sparam,dparam); } //+------------------------------------------------------------------+
Indicator:
#property indicator_chart_window #property indicator_applied_price PRICE_CLOSE //--- input parameters input long ChartID=0; input ushort EventID=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //--- if(prev_calculated) ::EventChartCustom(ChartID,EventID,rates_total,price[rates_total-1],_Symbol); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
You agree to website policy and terms of use
Hello
I'm trying to build a multi currency ea that works in the mt5 strategy tester.
i'm not a professional programmer but i tried i've read the articles on this website about that and tried but with no luck i couldn't understand the method because they use about 3-5 include files linking to each other and it became over overwhelming.
so please any one give me an example within a small direct code of how can i use the OnChartEvent() and the OnBookEvent() to check whether there is a tick on the other symbols or not.
Thanks in advance