You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Something more to trie did an update of my previous post while you were answering
If it all fails and it still not printing 123 Then you have to show more of your code
and take a notice to the link in the post of RaptorUK
OK, it's time for you to get to grips with doubles and their precision . . . have a read of this thread, carefully: https://www.mql5.com/en/forum/136997
Raptor i think the error is not there, the IF doesn't work even if i don't use NormalizeDouble and i used >= too so it's not a matter of precision, the ASK price obviously surpassed the OrderTakeProfit()-Value1*4 price
still doesn't print 123
here's more of my code:
here's more of my code: [...]
However, the bit which remains puzzling is that if OrderTakeProfit() is zero because no order has been selected, then the condition should be true; it should evaluate to "is Ask larger than a negative number ?"
If you don't do an OrderSelect(), then the value of OrderTakeProfit() is unpredictable. It may return 0, or it may return the t/p on a different order to the one you intend. Calling OrderSend() does not automatically select the order which has been created.
However, the bit which remains puzzling is that if OrderTakeProfit() is zero because no order has been selected, then the condition should be true; it should evaluate to "is Ask larger than a negative number ?"
Well it also wouldn't explain why the comment on page 1 shows the correct value( the one i wanted) plus as you said the condition should be true in either case
Well it also wouldn't explain why the comment on page 1 shows the correct value( the one i wanted) plus as you said the condition should be true in either case
The code is more than a little opaque, but what seems to be happening is as follows:
* Value1 holds the distance from the entry price to the (prospective) stoploss, e.g. 0.0020
* Immediately after placing an order you set the s/l and t/p. Your screenshot shows that this is working; the s/l line is visible.
* The t/p is set to 5 times the s/l (and is therefore off the top of the screenshot).
* Immediately after placing the order, the line of code in question is saying "is the ask price less than 4 times the s/l distance from the t/p?"
* I can't see how this can be true immediately after order placement. By definition, the ask price is 5 times the s/l away from the t/p
* These conditions apparently only get called immediately after order placement, in the buy() function. They are apparently not called on subsequent ticks. Therefore, the condition is going to be evaluated once only, at a time when it can't be true.
The code is more than a little opaque, but what seems to be happening is as follows:
* Value1 holds the distance from the entry price to the (prospective) stoploss, e.g. 0.0020
* Immediately after placing an order you set the s/l and t/p. Your screenshot shows that this is working; the s/l line is visible.
* The t/p is set to 5 times the s/l (and is therefore off the top of the screenshot).
* Immediately after placing the order, the line of code in question is saying "is the ask price less than 4 times the s/l distance from the t/p?"
* I can't see how this can be true immediately after order placement. By definition, the ask price is 5 times the s/l away from the t/p
* These conditions apparently only get called immediately after order placement, in the buy() function. They are apparently not called on subsequent ticks. Therefore, the condition is going to be evaluated once only, at a time when it can't be true.
This is exactly the problem.
Thank you guys for your time.
My brain hurts too much for today, i can't seem to trail my stops as i want, but when i'll be feeling better i'll try to fix it.