Forex Factory (https://www.forexfactory.com/)
-   Commercial Content (https://www.forexfactory.com/forum/158-commercial-content)
-   -   How can you limit the number of orders in each bar? (https://www.forexfactory.com/thread/64883-how-can-you-limit-the-number-of-orders)

JFonseca Jan 13, 2008 5:19pm | Post# 1

How can you limit the number of orders in each bar?
 
Hi,

Im coding my system,and Im having some problems trying to limit the number of open orders for each bar. In my system, the decision is made in the opening of a new bar, and if the conditions arent perfect, the EA should only reanalyse in the opening of next bar.

Ive tryed Volume[0] > 10, but sometimes it opens 2 orders because the EA runs a second time before Volume [0]>10 and sometimes it doesnt open any order because the Volume goes past 10 very quickly.

Can anyone help me?

Thanks,

J Fonseca

Mtav Jan 13, 2008 6:01pm | Post# 2

Hi,

Im coding my system,and Im having some problems trying to limit the number of open orders for each bar. In my system, the decision is made in the opening of a new bar, and if the conditions arent perfect, the EA should only reanalyse in the opening of next bar.

Ive tryed Volume[0] > 10, but sometimes it opens 2 orders because the EA runs a second time before Volume [0]>10 and sometimes it doesnt open any order because the Volume goes past 10 very quickly.

Can anyone help me?

Thanks,

J Fonseca
hi
use


if (XY != Time[0])
{
open order.....

....
XY=Time[0];
}

JFonseca Jan 14, 2008 12:33pm | Post# 3

Ive already tried
 
Hi,

I have already tried that with Open[0] and with Time[0] and none worked. I found out that when the EA returns to the beggining, it forgets the XY value.

I did this:

datetime XY;
Print ("before if XY = ", XY)
if (XY != Time[0])
{
Execute program
}
XY = Time [0];
Print ("End of program XY = ", XY)
return (0);
}

Whats wrong with this? How can I fix it?

Thanks,

J Fonseca

JFonseca Jan 14, 2008 12:55pm | Post# 4

Solved the problem!
 
Hi,

I already found out what the problem was. I declared a local variable, and should have declared a global variable.

J Fonseca

The Jedi Jan 14, 2008 1:03pm | Post# 5

Hi,

I already found out what the problem was. I declared a local variable, and should have declared a global variable.

J Fonseca
Good catch, was about to say that. Of course, don't forget to set a mechanism in there to clear the global variable at the start of every bar so that the system can reset.


© Forex Factory