Basic questions ...

To add comments, please log in or register
newoptionz
645
newoptionz  

Hi

I want to do the following in code

'Don't trade for 30 minutes since my last trade'

So if my indicators indicate that I should add to my current trade again then I place trade in the same direction only if 30minutes have past

I am doing the following - this code does work yet - it is just in design phase - I don't know how to add 30 minutes to my last order

This is for an EA only working on the current pair

int start()

{

int cnt, ticket, total, stop1;

static datetime lasttime

total=OrdersTotal();

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

//Determine the time of the last OrderClose

if (OrderCloseTime > lasttime + 30)

{

lasttime = orderclosetime

}//if (OrderCloseTime)

}

Now I want to say

if (Curtime() > lasttime + 30 minutes)

{

Contiue trading

}

pls help

mbkennel
8
mbkennel  

I think that looks fine, but in the check for the OrderCloseTime,

I don't see why you need the extra 30 minutes.

If the newest OrderCloseTime is more recent than the previous one, then it should be lasttime.

Sergey Golubev
Moderator
113796
Sergey Golubev  

if (Curtime() > lasttime + 30*60)

yaniv_av
108
yaniv_av  

Basic question ...

Hi,

I'm new with MetaTrader and have a basic question:

I want to limit the open positions in my expert-advisor to only 1 position at a time - but I want that limitation per symbol, so if I'll run another expert-advisor on another symbol, It will open a new position on that symbol.

In another words, I want to be able to open 1 positions for all the symbols, but not more than 1 position for a symbol (And I'm talking about many expert-advisor on many symbols...)

How can I do It ?

I saw the "totaltrades" function, but from the documentation I understood that this function applys to the account and not for the current symbol,

so "if totaltrades=1 then exit;" will cause to 1 position at a time for all the symbols...

10X !

AlexPiechFinGeR
1038
AlexPiechFinGeR  

1 positions for all the symbols

int total=OrdersTotal();

if(total<1)

{

.

.

.

}

Sergey Golubev
Moderator
113796
Sergey Golubev  

But one position for one symbol or for one chart opened?

yaniv_av
108
yaniv_av  

well, one per chart is the best ...

But if it can't be done, then 1 per symbol is also good...

AlexPiechFinGeR
1038
AlexPiechFinGeR  

1 per symbol

...

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() )

return(0);

....
yaniv_av
108
yaniv_av  

Great!

10X alot !

yaniv_av
108
yaniv_av  

And I'll bother u again ... (:

Can I do It also per chart ?

Because I have differents systems for differents time intervals charts ...

AlexPiechFinGeR
1038
AlexPiechFinGeR  

sorry im not understand

To add comments, please log in or register