How to code? - page 212

 

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

 
Kalenzo:
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.

}

Hi Kalenzo,

Thank you for the answer!

If the code correct ?

MagicNumber = 1000;

maxRepetitions = 20;

z = maxRepetitions;

magic = getMagic();

getMagic()

{

findmagic = MagicNumber+i;

for(int i=1;i<=z;i++)

{

for(int n=1;n<=openOrders;n++)

{

OrderSelect(n, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol())

{

if (OrderMagicNumber() != findmagic) continue;

magic = MagicNumber+i;

}

}

}

return(magic);

}

Thanks and regards

derumuro

 

derumuro

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.

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

}

derumuro:
Hi Kalenzo,

Thank you for the answer!

If the code correct ?

MagicNumber = 1000;

maxRepetitions = 20;

z = maxRepetitions;

magic = getMagic();

getMagic()

{

findmagic = MagicNumber+i;

for(int i=1;i<=z;i++)

{

for(int n=1;n<=openOrders;n++)

{

OrderSelect(n, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol()==Symbol())

{

if (OrderMagicNumber() != findmagic) continue;

magic = MagicNumber+i;

}

}

}

return(magic);

}

Thanks and regards

derumuro
 

Hi cockeyedcowboy,

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?

Regards

derumuro

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

Thank you, Roger09

 

Programmatically determining if market execution

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?

 

C.

If you go to metaquotes.net, you might find metatrader in your native langauge.

derumuro:
Hi cockeyedcowboy,

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?

Regards

derumuro
 

ATR value in csv - Script

HI, I have problem. I need import ATR value from metatrader to csv file.

Unfortunately I do not know how to do.

Please help me write the script.

I tried using FileWrite - MQL4 Documentation and iATR - MQL4 Documentation. But I failed it..

 
nondisclosure007:
C. If you go to metaquotes.net, you might find metatrader in your native langauge.

Thanks !

I'm looking for a good guide for MQL4

Regards

derumuro

 
derumuro:
Thanks !

I'm looking for a good guide for MQL4

Regards

derumuro

The one on the site is ok

MetaQuotes Language 4 - MQL4