|
|||||||
| 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 |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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! |
|
||||
|
Quote:
You CAN NOT back test multiple currencies using one EA in the back tester.![]() |
|
||||
|
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. |
|
||||
|
Quote:
#property copyright "Copyright © 2006, Bogie Enterprises"
__________________
|
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |