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.
Can anyone help me to better understand how to modify code to allow EA to execute simultaneous orders in several instances (in other words I am testing the same EA, on several pairs at once, and am using different magic numbers for each instance.)
The original code includes this:
int total=OrdersTotal();
if(total<1)
And I think this is where the problem is. If I increase the number, it merely executes several orders on the same bar (M15) for the same pair. If left if(total<1), then it will not allow for simultaneous orders on different pairs.
Can I change something about the tick or bar to allow only one order at a time per pair, but several orders for all pairs that have EA (with different magic number) attached??
Thanks to anyone who can help or offer input!
Chili
OrdersTotal is a built in function that doesn't consider magic number. You need to write your own function that utilizes OrdersTotal but filters by magic number and probably symbol too. There's plenty of examples around here and elsewhere.
I changed the StartDay to 0, and changed the StartHour to the current GMT hour of my broker, and changed the StartMinute to 5 minutes ahead of GMT minutes - It still does work right when the GMT time matches my start time. I looked at the help files and they do not show a multiple if statement. Multiple if statement always confuses me. What the heck am I doing wrong? I want the program to not trade until the appropriate start time on Sunday, and make a comment "Non-Trading Time" until the time = the start on Sunday time.
OrdersTotal is a built in function that doesn't consider magic number. You need to write your own function that utilizes OrdersTotal but filters by magic number and probably symbol too. There's plenty of examples around here and elsewhere.
Good luck.
Lux
Here is one I made and have used quite a bit:
PHP Code:
int OTBM(int intMagic)//OrdersTotalByMagic
{
int intCount=0;
int intPOS=0;
bool boolTerm=false;
while(boolTerm==false)
{
if(OrderSelect(intPOS,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
intPOS++;
}
else
boolTerm=true;
}
return(intCount);
}
And if you want to close only a certain order by magic number:
PHP Code:
int CBM(int intMagic)//CloseByMagic
{
int intOffset=0;
int Count = OTBM(intMagic);
An MA on any chart is just a higher/lower version of an MA on a higher/lower time frame. For example if you put a 60MA on a 5 min chart but want to see what it looks like on an hour chart you would just multiply 60 by 12 (5 min intervals in an hour). So a 720 MA on an hour chart is the same as a 60 MA on a 5 min chart.
Make sense?
Lux
Totally makes sense. How will you see a M5 10MA on a H1 chart?
10/12=0.84. Can you put a 0.84 MA on a H1 chart? No.
It works the other way though - H1 10MA = M5 120MA.
So my question is, how do I see a cross of 5MA on a higher Timeframe like H4.
I’m new to this forum & am learning MQL4 now by reading the MQL4 Course written by benevolent Coders’ Guru.
Though I hv some prior rudimental knowledge of computer, hardware & software, I’m sure there’d be many areas in which I need helps & advice from Guru & seniors here. So, please be kind & patient with me esp if I shd ask any silly questions or if the questions were asked before somewhere.
May I wish all here many Happy & Profitable Trades!
While reading the MQL4 Course by Coders' Guru I came across this part on 'for' loop in Lesson 5 that I'm confused. It says there can be one test expression only. But the examples shown contain 2 test expressions.
int i;
int j;
for(i=0,j=0;i<15,i<;i++,j++)
Print(i);
the expression may be a complex one using some logical operator. Example:
PHP Code:
for(i=0; i<10 && a+i<15; i+=2)
Thank you. I cld understand what you said. But the two examples given in the lesson I quoted don't seem to fall into this category. There is a comma between i<15 and i<; between i>0 and i<. I suspect there was typo error. What do you think? Need to get it out of the way to proceed further. Thx.
Thanks Lux and thank you Wolfe for your specific code. I am not good with code yet, but had found a specific example on the web that I already worked into EA:
int ExOrdersTotal(int MagicNumber)
{
int total = OrdersTotal();
int extotal = 0;
for(int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if ( OrderMagicNumber()==MagicNumber)
extotal++;
}
return (extotal);
}
I get an Error code:
"("- function definition unexpected
and have already defined MagicNumber
I have the EA set up on 5 pairs (with different magic numbers), but still no trades. I am beginning to suspect something is wrong.
These EAs are modified from Gordago's Elder 3X screens
which were modeled after MT4 MACD Sample. I have always had trouble with multiple pairs and orders with EAs that are modeled after these, but the Gordago has shown good backtesting results (I have had to modify code for optimization).
I will try with yours Wolfe, if I don't see a trade soon.