Your code is opening orders (although Marco is correct - you should check the return value in case of failure, and Carl is correct you shouldn't use NULL that way) and the logic is working as you have asked - see my post here.
I guess you're after something more like this:
if (sellcount_order()==0 && /*more conditions to open first sell order*/)
{
OrderSend(Symbol(),OP_SELL,.01,NULL,NULL,NULL,NULL,1,1,NULL,NULL);
}
if (buycount_order()==0 && /*more conditions to open first buy order*/)
{
OrderSend(Symbol(),OP_BUY,.01,NULL,NULL,NULL,NULL,1,1,NULL,NULL);
}
if (sellcount_order()==1 && /*more conditions to open second buy order*/)
{
OrderSend(Symbol(),OP_BUY,.01,NULL,NULL,NULL,NULL,2,2,NULL,NULL);
}
if (buycount_order()==1 && /*more conditions to open second sell order*/)
{
OrderSend(Symbol(),OP_SELL,.01,NULL,NULL,NULL,NULL,2,2,NULL,NULL);
}
NULL is not a valid price (double.) NULL is not a valid slippage (points.) NULL is not a valid SL (price.) NULL is not a valid TP (price.) NULL is not a valid datetime (expiration.) NULL is not a valid color.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check the return value of OrderSend()
Have you gone through your code with the debugger?
Well Id never done that before. I clicked the debugger in MetaEditor and nothing happened.
Gotta be a way to fix this problem.
Your code is opening orders (although Marco is correct - you should check the return value in case of failure, and Carl is correct you shouldn't use NULL that way) and the logic is working as you have asked - see my post here.
I guess you're after something more like this:
Well Id never done that before. I clicked the debugger in MetaEditor and nothing happened.
Gotta be a way to fix this problem.
If the green button in the editor to start the debugger is grey (not available) just do this:
If I try to debug an indicator with b1045 or b1052 it isn't working.
If so I can send you the old terminal b1031 but without any guaranty - you might have to delete the content of the config folder!
Don't forget to place Breakpoints (F9) to stop the debugger at specific lines!
Thanks all !! Got it down finally. Was a logic issue.
Second counter and magic numbers did it