Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #351 (permalink)  
Old 03-30-2008, 01:27 AM
MANSTIR's Avatar
MANSTIR MANSTIR is offline
Member
 
Join Date: Nov 2007
Posts: 78
MANSTIR is on a distinguished road
can someone check this code, its something wrong on some part..

when the ea sell and get profit,its keep going on and on non stop sell, same with buy too..what wrong with this code?..can someone fix it..

Last edited by Linuxser : 03-31-2008 at 02:30 AM. Reason: Copyrighted code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #352 (permalink)  
Old 03-30-2008, 08:05 PM
dan5767 dan5767 is offline
Junior Member
 
Join Date: Aug 2007
Posts: 5
dan5767 is on a distinguished road
Trade multiple currencies in one EA

Hi,
I just have a quick question. How do you trade multiple currencies with one EA so the statement has all of the currencies included. Right now I have to trade my EA on one currency at a time, and I want to see how the EA would perform on multiple currencies at the same time. This would make it a lot easer to see how the EA would perform on all currencies during a back test.

Thanks for your time!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #353 (permalink)  
Old 03-30-2008, 08:34 PM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by dan5767 View Post
Hi,
I just have a quick question. How do you trade multiple currencies with one EA so the statement has all of the currencies included. Right now I have to trade my EA on one currency at a time, and I want to see how the EA would perform on multiple currencies at the same time. This would make it a lot easer to see how the EA would perform on all currencies during a back test.

Thanks for your time!
You CAN trade multiple currencies with one EA. You CAN NOT back test multiple currencies using one EA in the back tester.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #354 (permalink)  
Old 03-30-2008, 10:50 PM
MiniMe's Avatar
MiniMe MiniMe is offline
Senior Member
 
Join Date: Nov 2006
Location: Montréal
Posts: 1,032
MiniMe is on a distinguished road
it would be easier to post the whole code , as the one you post doesn't compile
here is my comments
1- first you need to check OrderIsOpen=0 or 1 before you enter the loop , i think that is done by calling Mytotal() at start then set OrderIsOpen to 0 if Mytotal==0 and set OrderIsOpen to 1 if Mytotal==1

2- you don't need to keep using return(0) in the main code that would terminate the code
3- I am not able to compile the code as its missing the main function but I guess if you take care of the above points you should be ok

Last edited by MiniMe : 03-31-2008 at 02:20 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #355 (permalink)  
Old 03-31-2008, 02:01 AM
MANSTIR's Avatar
MANSTIR MANSTIR is offline
Member
 
Join Date: Nov 2007
Posts: 78
MANSTIR is on a distinguished road
thanks MiniMe for ya prompt reply;

heres i attach example of the ea...

Last edited by Linuxser : 03-31-2008 at 02:29 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #356 (permalink)  
Old 03-31-2008, 02:08 AM
MiniMe's Avatar
MiniMe MiniMe is offline
Senior Member
 
Join Date: Nov 2006
Location: Montréal
Posts: 1,032
MiniMe is on a distinguished road
Quote:
Originally Posted by MANSTIR View Post
thanks MiniMe for ya prompt reply;

heres i attach example of the ea...
see the private message please

Last edited by MiniMe : 03-31-2008 at 02:17 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #357 (permalink)  
Old 03-31-2008, 02:30 AM
Linuxser's Avatar
Linuxser Linuxser is offline
Moderator
 
Join Date: May 2006
Location: Helliconia (Autumn)
Posts: 2,165
Linuxser has disabled reputation
Quote:
Originally Posted by MANSTIR View Post
thanks MiniMe for ya prompt reply;

heres i attach example of the ea...
MANSTIR:

#property copyright "Copyright © 2006, Bogie Enterprises"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #358 (permalink)  
Old 03-31-2008, 02:40 AM
MANSTIR's Avatar
MANSTIR MANSTIR is offline
Member
 
Join Date: Nov 2007
Posts: 78
MANSTIR is on a distinguished road
Quote:
Originally Posted by Linuxser View Post
MANSTIR:

#property copyright "Copyright © 2006, Bogie Enterprises"
sorry for my mistake... thanks linuxser and minime

if still not suitable, please delete it, thanks

heres another example;
Attached Files
File Type: mq4 Automan.mq4 (9.2 KB, 4 views)

Last edited by MANSTIR : 03-31-2008 at 02:59 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #359 (permalink)  
Old 04-03-2008, 01:46 AM
ys16 ys16 is offline
Junior Member
 
Join Date: Mar 2008
Posts: 8
ys16 is on a distinguished road
A problem on my EA.

Dear experts,

I find a problem on my simple EA, which is when i want to close all positions in my account, the positions were not able to be closed at first price change. For example, if I have 10 positions, once I turn on my EA, the price changed from 1.9864 to 1.9865(1st run cycle),, only 5positions were closed. Then when price changed from 1.9865 to 1.9866(2nd run cycle), there were 3 positions closed. Finally, when the price changed from 1.9866 to 1.9865(3rd run cycle), the last two position were closed. Therefore, my 10 positions have not been closed at the same time.

After detailed debug, I knew that, in the first run, the for loop only was executed 4 loops although OrdersTotal()=10 here. And in the second cycle, there were only 3 loops were executed, although OrdersTotal()=5. in the last cycle, full loops were executed, which was 2 loops.

However, according to the MQL4 tutorial, the start function should be executed line by line and only when MetaTrader find the return keyword it will be ready to call start() function again with the most new quotation. That mean, the EA should close my all positions within one cycle, although, the close price may change because of the latest bid and ask price.

the following is my code, please spend a little time to read. and find out the reason of the stupid error of my EA.

Many thanks in advance!

int start()
{
int ticket=0;
double volume=0;
bool close=true;

Print ("we can account the number of times the price changes needed to close 10 positions");

for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if ( OrderType()==0)
{
ticket=OrderTicket();
volume=OrderLots();
close=OrderClose(ticket,volume,Bid,10,CLR_NONE);
Print ("position order is#",i);
if (close==false)
{
Print ("OrderClose failed with error1#",GetLastError());
}

}
else if ( OrderType()==1)
{
ticket=OrderTicket();
volume=OrderLots();
close=OrderClose(ticket,volume,Ask, 10,CLR_NONE);
Print ("position order is#",i);
if (close==false)
{
Print ("OrderClose failed with error2#",GetLastError());
}
}

else if ( OrderType()>=2)
{
ticket=OrderTicket();
close=OrderDelete(ticket);
Print ("position order is#",i);
if (close==false)
{
Print ("OrderDelete failed with error3#",GetLastError());
}
}

Print ("this is to test how many loops, the EA run", i);

}
return(0);
}

Last edited by ys16 : 04-03-2008 at 02:22 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #360 (permalink)  
Old 04-03-2008, 02:21 AM
ys16 ys16 is offline
Junior Member
 
Join Date: Mar 2008
Posts: 8
ys16 is on a distinguished road
The error code I found is 4051
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 06:04 PM
Learning to code for autotrading GoatT Metatrader Programming 8 01-10-2007 08:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 05:29 PM


All times are GMT. The time now is 09:22 AM.