Stop Loss widening (or removal) at Market closure

 

Good morning everyone,

I was wondering if there's a way (or if you know an existing EA) that allows you to widen (or remove) the SL for a couple of hours at market closure (due to spreads getting wider) and then putting SL back (or close the position) when spreads come back to normal.

I'm thinking that won't be difficult to write an EA to do it (getting the spread from Bid-Ask and if it's higher than X amount it should increase SL by X, then when back to normal), but maybe there's already a feature/an existing EA out there (that I couldn't find).

I'm trying to do this because it happened that my positions were closed at Night for the spread widening to >200. I'm also trying to figure out a better prop/broker but even with raw spread it seems to happen on all Props/Brokers.


Thank you all.

 

In my opinion this is not a good approach, better to use hidden SL since the beginning, using an EA to check if the SL value is hit and closing the trade.

From that hypotetic EA, you can choose to not check SL closures when spread is bigger than your wanted value.

 
Fabio Cavalloni #:

In my opinion this is not a good approach, better to use hidden SL since the beginning, using an EA to check if the SL value is hit and closing the trade.

From that hypotetic EA, you can choose to not check SL closures when spread is bigger than your wanted value.

So for example using Bid and Ask as SL to close the trade when price is hit. But now I'm confused so what I was trying to do may be useless. 
When spread widens if you are in a sell the SL should be activated later (because the Bid is lower than actual price). 
I'm confused regarding the attached picture. My trade on EurAud was closed due to spread going to 200. However it should've been closed when the green line reached the price (with even a little major loss).
Am I right or I'm getting extremely confused? 😅 

The hidden SL you mentioned would be compared with Actual price (ord Bid/Ask)?
Files:
 
There are no existing//known EA//utility that widens//removes SL during mid-night roll-over time.
  1. To widen SL - doesn't make sense (IMHO) as mid-night crazy spreads could get real wild and hit any widened SL.
  2. To remove SL before mid-night and reinstate SL after - you need to add this feature to EA on coding level (or do it manually).

Happy trading!
🙂

P.S. hidden SL - is still SL
 
EffePi #:
So for example using Bid and Ask as SL to close the trade when price is hit. But now I'm confused so what I was trying to do may be useless. 
When spread widens if you are in a sell the SL should be activated later (because the Bid is lower than actual price). 
I'm confused regarding the attached picture. My trade on EurAud was closed due to spread going to 200. However it should've been closed when the green line reached the price (with even a little major loss).
Am I right or I'm getting extremely confused? 😅 

The hidden SL you mentioned would be compared with Actual price (ord Bid/Ask)?
Buy trades are opened on Ask and closed on Bid.
Sell trades are opened on Bid and closed on Ask.

Green line in your screen is Bid, red line is Ask. You can see that all is correct :)


What I meant for "hidden SL" means to not set SL directly on trades but to handle a closure in loss with an EA, checking current Ask/Bid (or also "Close" of previous closed candle can be an idea!) and seeing if the distance from current price and trade opening price is more than X points you want to use as SL.

 
Fabio Cavalloni #:
Buy trades are opened on Ask and closed on Bid.
Sell trades are opened on Bid and closed on Ask.

Green line in your screen is Bid, red line is Ask. You can see that all is correct :)


What I meant for "hidden SL" means to not set SL directly on trades but to handle a closure in loss with an EA, checking current Ask/Bid (or also "Close" of previous closed candle can be an idea!) and seeing if the distance from current price and trade opening price is more than X points you want to use as SL.

Fabio thanks for clarification, the initial idea was right then I got confused by some AI answer (should never trust AI 🤣).

Also thanks for the idea, I will work on one by checking my SL with current price (or ask/bid).

Is there a way to automatically add EA to new pairs (when opening new trades), or you should always add the EA manually?
 
EffePi #:
Fabio thanks for clarification, the initial idea was right then I got confused by some AI answer (should never trust AI 🤣).

Also thanks for the idea, I will work on one by checking my SL with current price (or ask/bid).

Is there a way to automatically add EA to new pairs (when opening new trades), or you should always add the EA manually?

You can code your EA to check "hidden SL" on all symbols, and not only the chart symbol.

 
Fabio Cavalloni #:

You can code your EA to check "hidden SL" on all symbols, and not only the chart symbol.

I coded something similar but (since I'm usually opening trades from the phone) I set it to get the SL when set, then it becomes "hidden" and I can just move it closer. That way I can still control the SL, have the value set and move the SL from the app (making it wider to avoid auto closure for the spread).

I don't know if it's clear, anyway in the code I didn't specify to check just one symbol, everything seemed to work at first but sometimes (especially when I open new trades in the opposite direction when the previous has been closed) it closes the trades as soon as they are opened.
I think I should kind of "reset" the EA after a trade as been closed and probably I have to limit the EA to the attached Symbol (right now it's working on all the symbols but apparently when opening multiple trades it starts to make confusion).

Also I don't know why if si out a 'Comment' line (to read the SL) the EA doesn't work properly, I had to use the 'Print' function instead.

Any help/suggestion is appreciated.
 
Apparently I (kind of solved the issue), now I'm limiting the EA only to the attached charts.

The only issue now is that after a Sell trade is closed and a buy trade is open on the same Chart it's closed as soon as it get opened. Then if opened again it will remain open. It doesn't happen viceversa (from buy to sell).
I've tried to reset the variable after the trade is closed. 
Now I'm thinking to use removeEA() after trade is closed.

Is there a command (I wasn't able to find it) to check if a trade has been closed?
 
EffePi:

Good morning everyone,

I was wondering if there's a way (or if you know an existing EA) that allows you to widen (or remove) the SL for a couple of hours at market closure (due to spreads getting wider) and then putting SL back (or close the position) when spreads come back to normal.

I'm thinking that won't be difficult to write an EA to do it (getting the spread from Bid-Ask and if it's higher than X amount it should increase SL by X, then when back to normal), but maybe there's already a feature/an existing EA out there (that I couldn't find).

I'm trying to do this because it happened that my positions were closed at Night for the spread widening to >200. I'm also trying to figure out a better prop/broker but even with raw spread it seems to happen on all Props/Brokers.


Thank you all.

I have the same problem with manual trading due to spreads getting wider some trades are closed as it was not planned and desired.