Need Programming/General Idea Help:

 

Hello all,

I need some help coding this. Basically I need a optimized way of knowing when one type of pending order changes to market order and then delete the other type of pending orders. For example, lets say I have 1 Buy Stop and 1 Buy Limit, and the Buy Stop gets hit, meaning now its a Buy Order, I would like to delete the Buy Limit order. But I need it to be working even if someone closes the MT platform and reopens it. So I think using variables are out of question, I think, not sure though. Also if the process is the fastest that would be great too, as would like to delete the limit order as fast as possible as soon as the stop order is hit. If anyone out there can jump in and give me some ideas for coding this it would be greatly appreciated. Even if its not actual code but theoretical idea.

Here is what I was thinking to achieve this, maybe this is best way maybe somone out there knows better way. Hear me out...

Create limit order, then create stop order, but put a comment in stop order like STOPORDER, or something like that. then keep checking for the trade with the commend STOPORDER and look at the trade type, it should be BUYSTOP, when stop gets hit, and you look for that comment you will see the order is now BUY and it will be signal to delete the limit order.

Only problem is, if that particular order is in play now and comment is still there, the next stop order you create and put comment in and then do your normal lookup routine, you will find the original BUY order with comment in play and it will trigger the deletion of the limit order again. Not sure how to avoid that.

Another thought is to save the ticket # of the stop order in a file. And then read that file and save the ticket number read form file in memory variable, then when that ticket number becomes BUY order you delete the limit orders and at the same time delete the file too, so when next buystop order is sent it will save to a new file and process continue. If you close MT platform in the middle of the process, as long as you start MT platform on same machine it will read the file saved and read the ticket number saved into variable and then look for that ticket number and start the comparison process etc. I think I like this idea better, but not sure how fast this file create, read, write and delete process is.

Any help would be appreciated, thank you all in advance.

 

What you are asking for sounds really easy to me, unless I'm missing something here. You would just have to scan your current orders, keeping track of every type that is currently open (buy, buystop, buylimit, sell, etc.). When appropirate order exists (buy) delete other pending order (buystop or buylimit, depending on which one exists). Am I right? Something like this? What are you trying to achieve, KillerKhan?

 

Trying to code this strategy...

https://www.mql5.com/en/forum/176083

but in addition to whats in the strat, I want to use Stop Orders at Level 1 as well.

Killer