So I wrote this little script...

 

Hi Ladies and Gents,

Could someone take a look at my script and help me clean it up a little bit please?

Its based on a breakout strategy and places a stradle order if the market price hasn't hit and is not within the market spread yet, using 2 pending trades (buystop and sellstop).

If the market price has hit; if its an order going short, the script places an immediate sell order and exits without placing a pending order going long. if its a long trade, the script places the long trade and deletes the pending short trade.

The above orders work. However, how do i get the script to detect if the current market price is too close to the ask or bid price to place pending trades and execute an immediate trade instead? I can't figure this out at all!

This is one of 3 final items that I need to learn before I turn this into an EA, so any help will be of assistance. The other 2 being money management and how to place the trades at specific times (I think I saw this as a thread here actually).

I look forward to your constructive critisisms and advice.

Files:
blaze.mq4  2 kb
Reason: