OrderSend() Problem, it is crazy .. :(

[Deleted]  

Hello People,


we are working on an automated trading system like the most in here i would say ;)


The following is crazy..


We have a code structure, which should order a "buy", then do some things, an if some events are happening, it should execute a function which include the ordersend function.


e.g. : Buy... events .. buy <--- this buy, we cant get executed. It is impossible and we don't know why. We've tried to shoot some troubles by printing infos about the position, in which the code is doing wrong.


We've done the following:

OrderSend();

Sleep(500);

Print("The Order XY at the codeposition ABC was sent");

Sleep(50);


The mystic is, we are getting the "Print", but there are no orders. We cant understand why this is happening. :(


Anybody who is able to unterstand what i'm tryin to explain? Sry, I am from Germany and my english is just school-based. I hope it is enough.


If anybody know this problem, even a solution, you would make us very very happy. And thank you all so much, who will try to help us. :)


greetz from germany :)

Ian Venner
2397
Ian Venner  

did you get a ticket number returned by OrderSend() ?

Ian Venner
2397
Ian Venner  

to test your code you should do something like this:

int ticket = OrderSend(Symbol(),OP_BUY ....etc) ;

if(ticket < 0) //means a valid ticket was not returned

{

int err=GetLastError();

Alert("OrderSend Error = ", err);

}

Simon Gniadkowski
17400
Simon Gniadkowski  
Always check your return values and check for errors ( GetLastError )
[Deleted]  

hi,


thank you for responding. We had not tried yet.

When the strategy-function calls our own OrderSend-function, then nothing happened. But if we call this own OrderSend-function on start() or init(), everything is ok.

But, we tested, if the function would be called, by set the Print Function under the own ordersend function, the print function was executed. But not the ordersend, that strange, because the ordersend should be called before the print function is called.


We don't get a ticket number, because we haven't set the function to an int var. Shell we do this?

We cant unterstand, why the ordersend doesn't work in the stategyfunc.

Simon Gniadkowski
17400
Simon Gniadkowski  

OrderSend() returns a value . . .

https://docs.mql4.com/trading/OrderSend

qjol
3201
qjol  
SDC:

to test your code you should do something like this:

int ticket = OrderSend(Symbol(),OP_BUY ....etc) ;

if(ticket < 0) //means a valid ticket was not returned

{

int err=GetLastError();

Alert("OrderSend Error = ", err);

}

or

if (OrderSend(Symbol(),OP_BUY ....etc) < 0)
   {
   Alert("OrderSend Error = ", GetLastError());
   }
Save typing
[Deleted]  

hey


thank you so much for trying to help us!


ok, we are using the return value now. and we get a "-1". Has anyone an idea why? I mean, what are reasons for getting "-1"?

qjol
3201
qjol  
check (Alert() or Print()) if everything is ok like MarketInfo(Symbol(), MODE_STOPLEVEL), SL, TP, 4/5 Digits Broker
Simon Gniadkowski
17400
Simon Gniadkowski  
elmoxis:

hey

thank you so much for trying to help us!

ok, we are using the return value now. and we get a "-1". Has anyone an idea why? I mean, what are reasons for getting "-1"?

Show your code and maybe someone can help . . .
[Deleted]  

Start()

{

NewLong() // longs over and over will be opened.

}


Start()

{

StrategyFunc();

}


void StrategyFunc()

{

if (true)

{

NewLong(); // this long will be opened

Print("StartLong"); / this is printed in experts

}

if (true)

{

NewLong(); // nothing happend :?

Print("This Long was send because of event x"); // this is printed in experts

}

}


thank you :)