
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
Hmmmph, good call, but I tried like this and it still doesn't work .....
Hi
I think usually orders are looped through downwards, i.e. use
Also try modifying the order AFTER you have set your stoploss/ take profit settings and not before as it seems to be the case.
Oh ya RaptorUK I also did this changes after reading the link you gave .... but the TP SL still not working .....
I add a bool Modify ;
and change the ordermodify to this .
Once again, you are trying to use a value before it has been calculated
StopLossSettings and TakeProfitSettings are both zero when you try to modify the trade.
Even after reading my post you show more code that tries to use values in the OrderModify that have not been calculated yet!
You need to check the return values from your trading functions . . . then report the error when they fail along with any relevant variables, please read this: What are Function return values ? How do I use them ?
Here ^ ^ ^ ^ ^
3. Why are you using a function call instead of the predefined variable Ask?
... one reason for 3 is that Ask does not refresh during a call to start() whereas MarketInfo(..., MODE_ASK) does refresh. If you do anything time-consuming in start(), e.g. closing or modifying multiple orders, then MarketInfo() is safer.
In other words: use of Ask and Bid can create a latent bug in your code which only emerges over time as the code becomes more complicated. The benefits of using Ask and Bid - a tiny speed gain - are very questionable compared to the latent bug which they create.
The two outputs of the following code will typically be different on any liquid symbol:
... one reason for 3 is that [...]
I think there is a very old discussion on this forum which shows that RefreshRates() + Ask is microseconds faster than MarketInfo(). But I would still prefer to use MarketInfo() because it is easier to use MarketInfo() throughout than to remember to put RefreshRates() in the potentially-necessary places, creating a bug if you forget one or more of these necessary uses.
In other words: use of Ask and Bid can create a latent bug in your code which only emerges over time as the code becomes more complicated. The benefits of using Ask and Bid - a tiny speed gain - are very questionable compared to the latent bug which they create.
... In particular, use of Ask rather than MarketInfo can lead to an EA which works correctly in back-testing (where trade placement is instant, and prices do not move during trading) but does not work properly in live trading (where placement is not instant, and prices do move during trading).
The fun part is that people will tend to view this as broker slippage - e.g. "I did a Print() of Ask just before trading, and that proves the broker filled me at a worse price" - when the actual issue is a software bug (i.e. the ask price in Print() is stale).
... In particular, use of Ask rather than MarketInfo can lead to an EA which works correctly in back-testing (where trade placement is instant, and prices do not move during trading) but does not work properly in live trading (where placement is not instant, and prices do move during trading).
The fun part is that people will tend to view this as broker slippage - e.g. "I did a Print() of Ask just before trading, and that proves the broker filled me at a worse price" - when the actual issue is a software bug (i.e. the ask price in Print() is stale).