Request Stop loss based on Previous X Number of candles high/low

 
Hello,

Any expert advisor or script out there that when I open a trade it automatically places stop loss based on Previous X Number of candles high/low (Buy order the stop loss will be on previous X number of candles low and vise versa) . And not tied to any pair (open for all pairs and markets) on MT5 please ?
 
This can be implemented to any strategy breakout mainly. But the thing is I would like it to after I open the trade with any amount and any direction sell or buy, it instantly modifies the SL and TP as I explained above (stop loss will have different value based on the High (in case of a sell transaction) or Low (in case of buy transaction) of X amount of previous candles. As for the take profit we can make it as X amount of risk/reward (Like 1:1, 2:1, 3:1, 4:1 )). I don’t know if it can be an EA or Script that I can attach to any chart. Needs to be on MT5, any help from coders will be appreciated
 
 
Vladimir Karputov:
Code example: Stop Loss based on N High Low:

Thank you Vladimir. Is it possible to  make it add the stop loss in the trade based on that rectangle. I see I need to make it manually, can it be done automatically?

 
ysewellam :

Thank you Vladimir. Is it possible to  make it add the stop loss in the trade based on that rectangle. I see I need to make it manually, can it be done automatically?

This is exactly what the EA does: it sets Stop Loss by the size of the rectangle.

 
Vladimir Karputov:

This is exactly what the EA does: it sets Stop Loss by the size of the rectangle.

It is working perfect thank you I had something wrong in the settings. Ok can you add take  profit to it so the take profit can be for example  N  amount of stop loss (Like 1:1, 2:1, 3:1, 4:1 )

 
Vladimir Karputov #:

This is exactly what the EA does: it sets Stop Loss by the size of the rectangle.

Do you have a mql4 version of that code sir?
 
ysewellam #:

It is working perfect thank you I had something wrong in the settings. Ok can you add take  profit to it so the take profit can be for example  N  amount of stop loss (Like 1:1, 2:1, 3:1, 4:1 )

Abd Rahman Alamsyah #:
Do you have a mql4 version of that code sir?

If you have questions about published codes, please ask them in the appropriate code discussion thread (at the bottom of each code in the CodeBase there is a link 'Go to the discussion on the forum of traders') - so I can answer everyone at once, and not just you personally.

Reason: