Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-10-2005, 09:24 AM
Junior Member
 
Join Date: Nov 2005
Posts: 5
ferman is on a distinguished road
Red face need help - Open trades when starting my EA

Hi,

I have problem that not making sense:
sometimes after starting my EA (Backtesting mode) i see that i have open trades !
OrdersTotal() return 1 open trade

what can be my problem ?

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 11-15-2005, 11:54 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Exclamation

Quote:
Originally Posted by ferman
Hi,

I have problem that not making sense:
sometimes after starting my EA (Backtesting mode) i see that i have open trades !
OrdersTotal() return 1 open trade

what can be my problem ?

thanks
Hi ferman,

Is it working in forward mode?
Could I see the code?
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 11-16-2005, 09:27 AM
Junior Member
 
Join Date: Nov 2005
Posts: 5
ferman is on a distinguished road
open orders and skipping code lines

Quote:
Originally Posted by codersguru
Hi ferman,

Is it working in forward mode?
Could I see the code?
Hi Coders' Guru,

What is a "forward mode" ?
This is my simple EA code:

Code:
//+------------------EA1.mq4------------------------------------------------+
#property copyright "Ferman"
#property link      "http://www.metaquotes.net"
#include <stdlib.mqh>

int      ticket=0; 
extern double Lots=0.1;
extern int    Slippage=2;
extern bool   Skip = false;
//+------------------------------------------------------------------+
int init()
  {
   Print ("--- Init happened ---");  
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {

   Print("--- DE-Init happened --- ");
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
   double  Stoc=0;
   double  Stoc_pre_1_bar=0;
   double  Stoc_pre_2_bar=0;
   int     gle=0;

   
   Stoc=iStochastic(NULL,0,8,5,3,MODE_SMA,1,MODE_MAIN,0);
   Stoc_pre_1_bar=iStochastic(NULL,0,8,5,3,MODE_SMA,1,MODE_MAIN,1);
   Stoc_pre_2_bar=iStochastic(NULL,0,8,5,3,MODE_SMA,1,MODE_MAIN,2);
   
   Print("-----------",TimeToStr(iTime(NULL,PERIOD_H1,0),TIME_DATE|TIME_SECONDS),"-------------");
   Print("stoc = ", Stoc);
   Print("Stoc_pre_1_bar = ", Stoc_pre_1_bar);
   Print(OrdersTotal());
   
   if (OrdersTotal() < 1) 
    {
       //LONG TREN?
      if (Stoc >= 30 && Stoc < 35 && Stoc_pre_1_bar < Stoc )  // GO LONG !
      {
         
         if (!Skip)// Are we in long trend already ?, yes - lets skip it and wait for the next break
         {
            ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,NULL,0,White);
            gle=GetLastError();
            if(gle==0)
               Print("BUY  Ask=",Ask, " OrderTicket = ",ticket);
            else 
               Print("BUY-ERROR! Ask=",Ask," Stoc=",Stoc," gle=",gle);
                 
         }
      Skip = false; //wait for the next break
      return(0); 
      }
      return(0);

    }//if
   else // OredersTotal > 1 - Manage Open Orders
      {
         //Take Profit  or stop lost    
         if ((Stoc >= 90 ) || Stoc <= 10 )
         {
            Print("need to close orderticket: ",ticket); 
            if (OrderClose(ticket,Lots,Ask,5,Red))
               Print("Close  Ask=",Ask);
            else 
               Print ("Close  -----ERROR----- Ask=",Ask," Stoc=",Stoc," error desc: ",ErrorDescription(GetLastError()));
       
            return(0);
          }
       }
   
   return(0);
   }
//+------------------------------------------------------------------+
my problems are:

1) when starting my EA in backtesting mode (H1, EUR/USD, open price only), sometimes i see that i have already open orders (i am printing the OrdersTotal() in the start() func.)

2) i see sometimes that the program not starting in the begining ( i see prints that comes from the middle of the start() func', its like skipping some lines

3) in the results i see orders, and in the journal we see zero orders (OrdersTotal()=0) all the period of testing ...

4) the main() func. dont start every 1 hour, why is that ? (we can see the prints)

i inserts the beginnings of the results :
Code:
2005.11.14 14:10:20	2005.11.04 04:00  EA1 EURUSD,H1: 0
2005.11.14 14:10:20	2005.11.04 04:00  EA1 EURUSD,H1: Stoc_pre_1_bar = 26.4706
2005.11.14 14:10:19	2005.09.22 08:00  EA1 EURUSD,H1: Stoc_pre_1_bar = 13.3333
2005.11.14 14:10:19	2005.09.22 08:00  EA1 EURUSD,H1: stoc = 20.098
2005.11.14 14:10:19	2005.09.22 08:00  EA1 EURUSD,H1: -----------2005.09.22 08:00:00-------------
2005.11.14 14:10:19	2005.09.22 07:00  EA1 EURUSD,H1: 0
2005.11.14 14:10:19	2005.09.22 07:00  EA1 EURUSD,H1: Stoc_pre_1_bar = 3.2258
2005.11.14 14:10:19	2005.09.22 07:00  EA1 EURUSD,H1: stoc = 3.0612
2005.11.14 14:10:19	2005.09.22 07:00  EA1 EURUSD,H1: -----------2005.09.22 07:00:00-------------  we jump over many days !!! 
2005.11.14 14:10:19	2005.09.22 06:00  EA1 EURUSD,H1: 0
2005.11.14 14:10:18	2005.08.08 08:00  EA1 EURUSD,H1: stoc = 3.5088
2005.11.14 14:10:18	2005.08.08 08:00  EA1 EURUSD,H1: -----------2005.08.08 08:00:00-------------
2005.11.14 14:10:18	2005.08.08 07:00  EA1 EURUSD,H1: 0  zero orders all the testing time 
2005.11.14 14:10:18	2005.08.08 07:00  EA1 EURUSD,H1: Stoc_pre_1_bar = 12.3457
2005.11.14 14:10:18	2005.08.08 07:00  EA1 EURUSD,H1: stoc = 14.9254
2005.11.14 14:10:18	2005.08.08 07:00  EA1 EURUSD,H1: -----------2005.08.08 07:00:00-------------
2005.11.14 14:10:18	2005.08.08 06:00  EA1 EURUSD,H1: 0
2005.11.14 14:10:18	2005.08.08 06:00  EA1 EURUSD,H1: Stoc_pre_1_bar = 16.0494     <-- here we see skiping over some code lines 
i hope i send all the details for understanding my problems, thank you

Avi
__________________
FERMAN
--------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 11-17-2005, 05:41 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Text Log is working fine.

Quote:
Originally Posted by ferman
Hi Coders' Guru,

What is a "forward mode" ?
I mean the live trading mode.

Quote:
1) when starting my EA in backtesting mode (H1, EUR/USD, open price only), sometimes i see that i have already open orders (i am printing the OrdersTotal() in the start() func.)
I tested the sample a lot of times and I didn't notice that. (Please view the log attached)

Quote:
2) i see sometimes that the program not starting in the begining ( i see prints that comes from the middle of the start() func', its like skipping some lines
That didn't happen, check the log file attached.

Quote:
3) in the results i see orders, and in the journal we see zero orders (OrdersTotal()=0) all the period of testing ...
No, not all the OrdersTotal are zero (see the log), but must of them are zero because every opened order closed before the next open (see Result tab log).

Quote:
4) the main() func. dont start every 1 hour, why is that ? (we can see the prints)
Do you mean strat() function? It starts every 1 hour(see the log)

Please see the attached log and tell me what do you think?
Attached Files
File Type: zip 20051117.zip (59.9 KB, 21 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 11-19-2005, 02:54 PM
Junior Member
 
Join Date: Nov 2005
Posts: 5
ferman is on a distinguished road
Quote:
Originally Posted by codersguru
I mean the live trading mode.


I tested the sample a lot of times and I didn't notice that. (Please view the log attached)


That didn't happen, check the log file attached.


No, not all the OrdersTotal are zero (see the log), but must of them are zero because every opened order closed before the next open (see Result tab log).


Do you mean strat() function? It starts every 1 hour(see the log)

Please see the attached log and tell me what do you think?

Thanks, codersguru for your answers.
It seems that verything ok with youe tests, i don't know what to say.
but, today i noticed that when reducing the amount of printing to the journal, those symptoms are goon ! (i have 4 print lines for every tick it the start() )

do you familiar with this problem ?
does a lot of printing ( print() ) to the journal can cause problems ?


Thank you
__________________
FERMAN
--------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Close Open Trades EAs based on Equity Tradinator Expert Advisors - Metatrader 4 32 11-10-2009 04:26 PM
Maximum number of open trades per MT4 account fxtrader625 Metatrader 4 10 06-07-2007 07:59 PM
MT4 is there a "close all open trades script/command?" keramikus Metatrader 4 3 05-29-2007 02:49 PM
EA to manage open trades richo12 Suggestions for Trading Systems 6 08-28-2006 09:22 PM
close all open trades ea G-Riper General Discussion 2 08-02-2006 10:41 PM


All times are GMT. The time now is 07:59 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.