Help! How to set a stop loss that does NOT trigger when the price is reached, but instead ONLY if the candle can CLOSE past that level.

 

I have been trading for a while now and one technique I use for my stops, is that I stop out the trade ONLY if price can CLOSE past my stop level. However, it doesn't seem that MT4 has a built in function for this. I have been looking all over the internet for quite some time and cannot find any solution. Please help. Is there an EA or something out there can enable a stop loss like this?

 

Code the stop level as a variable and then test if your close is beyond this point. Obviously, you wouldn't send this stop level to the broker but I would recommend retaining an actual stop loss at some safe distance.... would hate to lose your connection when reliant on the EA to close.

hth

V

 
int stopValue = 1.2345; // example

int oldTime;

init(){

   oldTime = Time[0]); // set your time watcher
   
   return(0);
}


start(){


   ... // Do your stuff to make a trade, close in profit, etc

   if(oldTime != Time[0]){       // suddenly there is a new bar, so the old current bar just closed
      if(Close[1] > stopValue){  // and if the close is above your stop
         CloseTrades();          // close your trade
      }
   }
   oldTime = Time[0];      // reset the time watcher so any new trades won't close with stopValue during this bar
   return(0);
}
 
phy:
Why all the newbar code?
if(Close[1] > stopValue){  // and if the close is above your stop
         CloseTrades();

This line does the same thing. The first tick of the new bar sees Close[1] triggers stop so executes the order close. Job done....

V

 

Thought Experiment:

Bid = 1.2500 Close[1] = 1.2550

short at 1.2500, 20 pip stop...

What happens?

During the next tick (or even the same tick) your simplification exits the trade.

 
tentrade001:

I stop out the trade ONLY if price can CLOSE past my stop level.

Since price can move anywhere, you can't ever know if price can close. You must wait for the close and then check. Run a trailing stop say 50 pips below Bid in case you get disconnected. Then check at new bar whither to close with the real stop level.
 
phy:

Thought Experiment:

Bid = 1.2500 Close[1] = 1.2550

short at 1.2500, 20 pip stop...

What happens?

During the next tick (or even the same tick) your simplification exits the trade.

Thunk and understood... I normally wait for my third or forth back test before working things like that out :)

V

 
phy:


Thank you so much for responding. I would have wrote back sooner, but for some reason I didn't get an email telling me that there were replies.

Ok, so it can be done. But I need a little more help on implementing this. Even though I've been trading using MT4 for a couple of years, I'm not a programmer, and don't use EA's.

The way you wrote it out is assuming that the trade is also executed by the EA. However, most of my trades are either entered manually, or by orders that I have set manually. What i would like, is to be able to set the regular stop in MT4 for emergencies, and then also add the stop based on close to these trades. How can I do this?

Thank you so much for helping, I was going crazy with this!

 

At the top of the hour manually send an order to close if your conditions are met.

 
phy:

At the top of the hour manually send an order to close if your conditions are met.


The only reason I am not using that approach is because I enter about 30 new trades a day, all that i have to manually enter at that time. Some of the trades are open for days to weeks. This means I have over 100 trades open at the same time. It would be nearly impossible to manually manage them all in a timely fashion whilst also entering my new positions. All of this would have to be done almost simultaneously. That's why i'm trying to automate it some way.

Do you have any other ideas?

Thanks.

 

Write code to send an order to close if your conditions are met.