Unexpected result in Strategy Tester
  #1 (permalink)  
Old 08-23-2007, 09:01 PM
Freshman
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Alvo is on a distinguished road
Default Unexpected result in Strategy Tester

Hi,

I'm just starting to learn MQL4.

I want to make the classic example of looking for EMA crosses:

Code:
//+------------------------------------------------------------------+ //| cross_alert.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //---- input parameters extern int ShortPeriod=5; extern int LongPeriod=10; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- double MA_short_cur=iMA(Symbol(),0,ShortPeriod,0,MODE_EMA,PRICE_CLOSE,0); double MA_long_cur=iMA(Symbol(),0,LongPeriod,0,MODE_EMA,PRICE_CLOSE,0); double MA_short_prev=iMA(Symbol(),0,ShortPeriod,0,MODE_EMA,PRICE_CLOSE,1); double MA_long_prev=iMA(Symbol(),0,LongPeriod,0,MODE_EMA,PRICE_CLOSE,1); // check cross up if (MA_short_prev<MA_long_prev && MA_short_cur>MA_long_cur) { Print("Cross UP"); } // check cross down if (MA_short_prev>MA_long_prev && MA_short_cur<MA_long_cur) { Print("Cross DOWN"); } //---- return(0); } //+------------------------------------------------------------------+
I run it on GBPUSD on the daily chart and it detects the crosses well but the output in the Journal tab is pretty weird. For example there is a cross on 2007.07.27 and this is what I see in the Journal (it is the same at any other cross as well):

Code:
2007.08.23 22:04:04 2007.07.27 23:59 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 22:40 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 22:00 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 21:20 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 20:40 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 20:00 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 19:59 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 18:40 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 18:00 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 17:20 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 16:40 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 16:00 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 15:59 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 14:40 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 14:00 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 13:20 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 12:00 cross_alert GBPUSD,Daily: Cross DOWN 2007.08.23 22:04:04 2007.07.27 10:00 cross_alert GBPUSD,Daily: Cross DOWN
I have no intention to use this code to execute any order but if I did would it execute 18 orders???

How can I fix this to have only one single entry for each cross?

Thanks for your help!

Alvo
Reply With Quote
  #2 (permalink)  
Old 11-21-2007, 01:45 AM
Freshman
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sigitsln is on a distinguished road
Send a message via Yahoo to sigitsln
Default

Dear Alvo,
Would you please advice me, where the links is, if I want to learn MQL4, too. I thank you in advance.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
strategy tester ?????? max69 MetaTrader and ZeroCode 5 09-28-2007 04:18 PM
Strategy Tester - virtual chart not active chart? joc_06 MetaTrader and ZeroCode 0 08-11-2007 04:41 PM
Recall result of last trade trevman MetaTrader and ZeroCode 0 07-10-2007 07:21 PM
Forex Tester - professional training software for traders. meditator Classified Ads 3 12-22-2006 08:20 PM


All times are GMT. The time now is 11:58 AM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0

Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now