Problem with 1st order ticket number - page 3

 
RaptorUK:
there can always be a condition when using Pending orders that you might want to Delete it just as it's being activated

If the market is closer than MarketInfo(Symbol(), MODE_STOPLEVEL)*Point to the TP/SL, you can not modify the stops or close it. If the market is closer to open price of a pending order, it can not be deleted.

ERR_TRADE_MODIFY_DENIED 145 Modification denied because order too close to market.

 
WHRoeder:

If the market is closer than MarketInfo(Symbol(), MODE_STOPLEVEL)*Point to the TP/SL, you can not modify the stops or close it. If the market is closer to open price of a pending order, it can not be deleted.

ERR_TRADE_MODIFY_DENIED 145 Modification denied because order too close to market.

I have tried some code that closes all market orders at the same time as when I delete the existing pending orders - and now all kinds of weird things are happening!

A new Buy order is immediately opened with a lot size of 0.01 (which is not even allowed by my ECN broker!) where the smallest lot size before was 1.66 and went as high as double that! Where does it get this strange lot size? I did not touch any code that has to do with lot size! I also studied the code and there is NO WAY it can arrive at a lot size that small! It is as if the system has made up its mind that it WILL have a Buy market order no matter what I do to delete/close it and will create one out of the blue (there is NO code to create ANY Buy market orders in my system!!) and will find any size of lot to be able to do it. I am starting to believe in poltergeists!

What I need (except for killing this pending/Buy order dead so that it cannot arise again) is to have the control to force the sequence of transactions that take place in the same bar - although not same tick event. In other words to control the sequence of transactions that take place on the broker's server such as profit target, stop loss and activating a pending order into a market order.

Is that at all possible?

 
ernest02:

In other words to control the sequence of transactions that take place on the broker's server such as profit target, stop loss and activating a pending order into a market order.

Is that at all possible?


I don't believe it is . . . imagine if your EA went offline . . SLs TPs and Pending Orders would still be taken . . . they are all in the control of the Broker unless you change them or cancel them. IMO the only way you can have that kind of control is if you don't use SLs TPs or Pending orders and you close orders manually from your code and place all orders as market orders . . . bit I wouldn't suggest it as a solution.

Perhaps you need to step back, re-think your code . . . draw some flowcharts, write a little pseudo code . . .

 
RaptorUK:

I don't believe it is . . . imagine if your EA went offline . . SLs TPs and Pending Orders would still be taken . . . they are all in the control of the Broker unless you change them or cancel them. IMO the only way you can have that kind of control is if you don't use SLs TPs or Pending orders and you close orders manually from your code and place all orders as market orders . . . bit I wouldn't suggest it as a solution.

Perhaps you need to step back, re-think your code . . . draw some flowcharts, write a little pseudo code . . .

I think you are right. I am knocking my head against a brick wall! Unfortunately my strategy demands this near simultaneous activation of events. I may have to drop this idea after weeks of hard work. How distressing! And it was looking so promising in preliminary tests!

By the way is there NO book or course that can teach the subtleties of MQL4 programming? I bough a book on MQL4 programming but it covers only the basics. It is the things left out that is costing me days of nearly fruitless struggle and frustration. I cannot find ANY resource that have in one place all the hidden and tricky things that make this MQL4 programming so frustrating and time wasting for beginners.

 
I have no idea about books, sorry . . . I'm a slow reader so books take a lot of time for me to get anything useful from them, I usually use them just as a reference. I completely understand your frustrations, I have spend all day working on something that would have probably been done in an hours if MT4 came with a decent debugger . . being able to step through the code line by line and watching variables would make life so much easier . . but it isn't to be so we have to do the best with what we have.
 
RaptorUK:
I have no idea about books, sorry . . . I'm a slow reader so books take a lot of time for me to get anything useful from them, I usually use them just as a reference. I completely understand your frustrations, I have spend all day working on something that would have probably been done in an hours if MT4 came with a decent debugger . . being able to step through the code line by line and watching variables would make life so much easier . . but it isn't to be so we have to do the best with what we have.

Well, thanks for sticking with me and my problem and searching for a solution for such a long time!

IT IS GREATLY APPRECIATED!!

 
ernest02:

Well, thanks for sticking with me and my problem and searching for a solution for such a long time!

IT IS GREATLY APPRECIATED!!



For what I can try to contribute or help with, you are most welcome . . . the sane ones of us here need to stick together LOL ;-)