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
  #1481 (permalink)  
Old 05-11-2009, 03:04 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Quote:
Originally Posted by Chilibowl View Post
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.

Good luck.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
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
  #1482 (permalink)  
Old 05-11-2009, 06:18 AM
1Dave7's Avatar
Senior Member
 
Join Date: Aug 2007
Posts: 183
1Dave7 is on a distinguished road
Red face

Quote:
Originally Posted by luxinterior View Post
Take another look at the help file.



Lux
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.

Highly confused!!



?????
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
  #1483 (permalink)  
Old 05-11-2009, 06:59 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
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()==intMagicintCount++;
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);

while(
OTBM(intMagic)>&& Count 0)
{
OrderSelect(intOffset,SELECT_BY_POS);
if(
OrderMagicNumber()==intMagic)
{
if(
OrderType()==OP_BUYOrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),999,Red);
else if(
OrderType()==OP_SELLOrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),999,Orange);
Count--;
}
else {
intOffset++;
}
}
return(
0);

Order Profit By Magic:

PHP Code:
double OPBM(int intMagic)//OrderProfitByMagic
{
double dblProfit=0;
int intPOS=0;
bool boolTerm=false;
while(
boolTerm==false)
{
if(
OrderSelect(intPOS,SELECT_BY_POS))
{
if(
OrderMagicNumber()==intMagicdblProfit=dblProfit+OrderProfit();
intPOS++;
}
else
boolTerm=true;
}
return(
dblProfit);

Hope that helps.
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
  #1484 (permalink)  
Old 05-11-2009, 09:49 AM
Member
 
Join Date: Jan 2009
Posts: 33
JForex78 is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
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.

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
  #1485 (permalink)  
Old 05-11-2009, 10:26 AM
Junior Member
 
Join Date: May 2009
Posts: 9
abundance is on a distinguished road
Thumbs up Greetings from a Newbie!

Hello Coders' Guru & Fellow Seniors

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!

Henry
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
  #1486 (permalink)  
Old 05-11-2009, 02:44 PM
Junior Member
 
Join Date: May 2009
Posts: 9
abundance is on a distinguished road
Question for Loop on MQL4

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);


int i;
for(i=15;i>0,i<;i--)
Print(i);


Cld someone kindly enlighten?

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
  #1487 (permalink)  
Old 05-11-2009, 08:29 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by abundance View Post
... It says there can be one test expression only...
the expression may be a complex one using some logical operator. Example:
PHP Code:
for(i=0i<10 && a+i<15i+=2
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
  #1488 (permalink)  
Old 05-11-2009, 09:01 PM
Junior Member
 
Join Date: May 2009
Posts: 4
dyoser is on a distinguished road
TSF Indicator

Hi, how can i pick data from an indicator from an expert advisor?

I use a third-party TSF indicator and i wanto to use the values on my automate ea to make trading.... how can this be done?

I tried to take the code of the indicator to the ea, but for some reasons this does not work well...

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
  #1489 (permalink)  
Old 05-12-2009, 01:30 AM
Junior Member
 
Join Date: May 2009
Posts: 9
abundance is on a distinguished road
Question

Quote:
Originally Posted by Michel View Post
the expression may be a complex one using some logical operator. Example:
PHP Code:
for(i=0i<10 && a+i<15i+=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.
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
  #1490 (permalink)  
Old 05-12-2009, 01:56 AM
Member
 
Join Date: Nov 2008
Location: Texas
Posts: 32
Chilibowl is on a distinguished road
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.

Thanks
Chili
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

Tags
forex, histogram, JMASlope, ToR 1.20, ZUP_v1.mq4


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


All times are GMT. The time now is 08:33 PM.



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