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.
I will open in a EA 20 orders with different Magic Numbers.
Example:
- openOrders = 5 with Magic Number 1 to 5
- Order No. 4 will be closed, Magic Number 4 = free
- if new order is to open, I get this the smallest free Magic Number
How to program it ?
Thanks !
Regards
derumuro
First define getMagic() function which will give you magic numbers and put it in the ordersend function (as a parameter for setting the magic number).
Then indisde the get magic function you should do the following :
getMagic()
{
1) set loop for(int i = 1;i<21;i++) to check numbers from 1 to 20
2) next, do another loop (inside the first for) per each i number with for loop from 0 to OrdersTotal checking if you found the magic number equals i ,if you didn't found your magic number then it means that it is free and you can use it as return value of this function (getMagic) and pass it to the orderSend function, otherwise use contunue keyword to skip to another check of the magic number.
}
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................ http://www.fxservice.eu/
........................................
Now I need to know is the closing price for a specific bar is on each day. The would help me monitor the relative move in price to the close of the US DJIA stock index.
Any further assistance would be appreciated, thank you.
Now I need to know is the closing price for a specific bar is on each day. The would help me monitor the relative move in price to the close of the US DJIA stock index.
Any further assistance would be appreciated, thank you.
If you need bars only, use:
double iClose( string symbol, int timeframe, int shift)
where "shift" - is a proper bar.
What I'm looking for is the closing price of the same bar for each day, specifically 19:59:00 GMT closing price (the time at which the DJIA closes in the UK).
iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(),PERIO D_M1,StrToTime("19:59")));
Whilst your line of code worked perfectly, unfortunately it was only in my head that I thought it would show me the previous days closing prices too. The idea behind this is to mark the closing price of the 19:59:00 bar with an object so as to indicate the closing time of the DJIA and at what price the EURUSD was at that time.
So that's the closing price at a specific time each day; the closing price at 19:59:00 Mon-Fri.
int today=StrToTime("19:59");
int yesterday=StrToTime("19:59")-3600*24;
int twodaysbeforeyesterday=StrToTime("19:59")-3600*24*3;
so
double closetwodaysbeforeyesterday=iClose(Symbol(),PERIOD _M1,iBarShift(Symbol(),PERIO D_M1,StrToTime("19:59")-3600*24*3));
First define getMagic() function which will give you magic numbers and put it in the ordersend function (as a parameter for setting the magic number).
Then indisde the get magic function you should do the following :
getMagic()
{
1) set loop for(int i = 1;i<21;i++) to check numbers from 1 to 20
2) next, do another loop (inside the first for) per each i number with for loop from 0 to OrdersTotal checking if you found the magic number equals i ,if you didn't found your magic number then it means that it is free and you can use it as return value of this function (getMagic) and pass it to the orderSend function, otherwise use contunue keyword to skip to another check of the magic number.
}
If I understand your request this is more what your looking for.
You should study the way variables are shared between functions and global scope, you will have major problems if you dont understand the differences between local and gobal scope.
You should deturmine how to handle the situation were all 20 orders are placed. do you want to return a negative number? to let the program know that no more orders are allowed. There must be a safty built into your code.
Code:
int MagicNumber = 1000;
int maxRepetitions = 20;
int magic = getMagic( MagicNumber, maxRepetitions );
int getMagic( int StartNumber, int Repeat ) {
// CN!{if an error or no open MagicNumbers are avaible it will return -1}:
int ReturnNumber = -1;
for( int i = 1; i <= Repeat; i ++ ) {
for( int n = 0; n <= OrdersTotal(); n ++ ) {
OrderSelect( n, SELECT_BY_POS, MODE_TRADES );
if( OrderSymbol() == Symbol() ) {
if( OrderMagicNumber() != StartNumber + i ) continue;
ReturnNumber = StartNumber + i;
}
}
}
return( ReturnNumber );
}
thank you for your help!
I'm not a programmer. I try to learn MQL4, but I have 3 major problems.
1. I understand very little english.
2 I have not found a good guide to MQL4.
3. I have no one to help me.
Question: There is a programming language that is similar MQL4?
int today=StrToTime("19:59");
int yesterday=StrToTime("19:59")-3600*24;
int twodaysbeforeyesterday=StrToTime("19:59")-3600*24*3;
so
double closetwodaysbeforeyesterday=iClose(Symbol(),PERIOD _M1,iBarShift(Symbol(),PERIO D_M1,StrToTime("19:59")-3600*24*3));
Anyone know if there is a way to programmatically determine whether an order needs to be opened with "market execution" or if stoploss / takeprofits are allowed in the initial order?
__________________
Visit http://www.openthinkingsystems.com for EA signal distribution systems, MetaTrader and Collective2 integration and general custom development.