Following the recent success with
Old Ways
As I’ve already written, adding OnTick()
function. But that method has one big disadvantage — you’ll get ticks only from the chart, which has your EA attached to it, but they won’t necessarily coincide with the ticks on the charts for other currency pairs you wish to trade. This, as a result, creates an opportunity for a faulty behavior of the expert advisor. Of course, if your strategy is a
Spying on Charts
Konstantin Gruzdev in his article on The Implementation of a OnTick()
in OnChartEvent()
standard handler to trade — it just has to check for, which pair was the event generated for, and then use run a usual trade routines for it. You can freely download this simple Spy indicator or see his code here:
#property indicator_chart_window input long chart_id = 0; input ushort custom_event_id = 0; //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { EventChartCustom(chart_id, custom_event_id, (long)_Period, price[rates_total - 1], _Symbol); return(rates_total); } |
input long chart_id = 0;
input ushort custom_event_id = 0;
//+——————————————————————+
//| Custom indicator iteration function |
//+——————————————————————+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
EventChartCustom(chart_id, custom_event_id, (long)_Period, price[rates_total – 1], _Symbol);
return(rates_total);
}
With the iCustom()
function, a OnChartEvent()
handler instead of OnTick()
. That’s the whole difference between the old
New Testing Results
Testing the new EA on the period from 2011.01.01 till 2011.07.01 on EUR/GBP H1 resulted in $247,461.84 profit, which isn’t bad considering a quadruple increase over the profit of EUR/GBP
In the next issue of this journal, I’ll show you how to configure the position sizing functions to comply with the ATC 2011 rule that limits the maximum volume of one order with 5 standard lots.
If you are wondering what this post is all about, please read my first post in RTATC2011 series.
P.S.: 2 months and 17 days left for registration in ATC 2011. 857 participants registered so far.
If you have any questions regarding my implementation of the