Experts: TradeProtector-1.0 - Automatic Stop Loss and proprotional Trailing Stop

 

TradeProtector-1.0 - Automatic Stop Loss and proprotional Trailing Stop:

If you have placed order and suddenly have to leave: don't panic! This EA will set initial SL (if you haven't done it yet), and after your position will reach settable profit threshold, TradeProtector will start to apply proportional trailing stop. Not t

Author: Marek

 

very nice and useful!

I'll be armed with it.

Would you like to publish this Adviser in russian mirror of the site? In that case I would like to translate your article with my pleasure.)


***
All my indicators:

https://www.mql5.com/en/users/denis_orlov/publications
***

USE AND PROSPER!

 
@denis_orlov :

болшое спасиба!

I have to find russian keyboard mapping, cos my keyboard is English/Arabic :-)
Please go ahead, you are welcome to translate it.

But I have noticed, there is something even better:

http://codebase.mql4.com/5996

But it's more complicated so maybe my little dirty code can be useful for someone who needs something simple and easy.

Use and prosper too! (I like it very much, are you too a fan of Star Trek/ Mr. Spock ?)

 

болшое спасиба! - How did you type that if your keyboard is English/Arabic ? )

No, the coincidence with the famous motto of Mr. Spock is purely accidental.) Though I like that movie too.

When I send you the translated text, there will be no need of using russian keyboard, just filling the standart similar form in the russian mirror.

I'll do it soon.

And I'll think about Orders Guardian.

Thank you for the possibility to bring your idea to russian users.)

 

HERE WE GO:

Если Вы открыли ордер и внезапно должны уехать: не паникуйте! Советник установит начальный StopLoss (если Вы не сделали этого), и пропорциональный Трейлинг Стоп после достижения предустановленного значения прибыли.

Идея относительно этого советника пришла ко мне после следующей ситуации: я открыл позицию, но внезапно должен был уехать. Я установил разумный StopLoss, но что получилось:

В течение моего отсутствия, моя позиция достигла 40 пипсов прибыли, затем рынок полностью изменился и вместо какой-либо прибыли, был достигнут начальный StopLoss , небольшой, но все же лишний.

Я не люблю использовать трейлинг стопы, потому что, когда сильный тренд, и, скажем, мы имеем после нескольких часов 120 пипсов прибыли, трейлинг стоп, разумно установленный вначале на 35, теперь может уничтожить эту хорошую выигрышную позицию, если будет 38%-ая коррекция.

Именно поэтому я предпочитаю пропорциональный трейлинг стоп, заданный формулой:

ProportionalSL

= ( Текущая Цена - Цена открытия ордера )* Коэффициент - Спред

Скажем, я установил Коэффициент на 55 %. В примере выше я получил бы приблизительно 15 прибыли, которая лучше чем ничего, но если бы тенденция продолжилась, 40%-ая коррекция (0.38 Фибо) - независимо от точки поворота - не прервала бы моей торговли.

Есть также функция, относительно которой я не уверен, и по умолчанию она выключена. Я назвал её Escape (Выход) - когда ваша торговля достигает внушительной просадки, Вы обычно бываете счастливы закрыть её даже с очень маленькой прибылью, или даже - с менее внушительным убытком. Таким образом Вы можете установить 'тревожный' уровень просадки после, которой Вы хотели бы активизировать эту функцию, чтобы затем получить прибыль или мини-убыток и закрыть торговлю. В большинстве случаев - если должным образом установлены

StopLoss-ы, это не будет необходимо, но я решил оставить это в коде, на всякий случай...

Таким образом, мы здесь имеем:

Поместите Советник на график M1 или M5.

Установите:

logging=1 - если Вы хотите вести лог в каталоге Experts\Files

nTrailingStop

[ в пунктах ] - начальный трейлинг стоп. Он будет использоваться, пока ваша торговля не достигнет прибыли = nPropSLThreshold

nPropSLThreshold

[ в пунктах ] - после достижения этой прибыли будет использоваться пропорциональный трейлинг стоп

dPropSLRatio

[десятичное число] - Коэффициент (PropSL = Прибыль * Коэффициент - Спрэд)

nUseEscape

[1 или 0] - покинуть неудачные позиции, как только они достигают некоторой минимальной прибыли

nEscapeLevel

[ в пунктах ] - размер убытка (просадки) после которого мы бы решили покинуть позицию сразу после получения прибыли nEscapeTP

nEscapeTP

[ в пунктах ] - уровень прибыли в пунктах (Вы можете установить в отрицательное значение - тогда это будет уровень убытка, до которого Вы были бы счастливы добраться и закрыться, в случае, если ваша торговля достигла внушительной просадки).

***

Перевод:

Денис Орлов

http://denis-or-love.narod.ru

http://codebase.mql4.com/ru/author/denis_orlov

 

Hello!

I've been added some functionality to your code, to open positions on certain events, that is works great, and i didnt had to touch the ModifyOrders() function, but still it does some suspicious things i just cant explain.


And it does it, all the time, it finds the worst position that just can find to close the order. Can you please explain me the reason, why it does that?

All the settings are at default, you provided with your code.

 

Well, I have published your code with translated article for russian users.

Thank you for the permission.

'TradeProtector-1.0 Автоматический СтопЛосс и пропорциональный Трейлинг стоп'

 
to spockman :

First I would like to emphasize: the purpose of this simple adviser is not to maximize a profit, but to minimize loses!
Especially when you suddenly have to leave your trades unattended.

The idea boils down to: don't let my positions to generate draw-down - if there is any profit, just make sure there will be no lose.
And algorithm is very simple: as long as there is lose, keep trailing SL at pre-defined interval (simple trailing stop), once the position reached defined profit level - set SL between open price and current price.

(btw. I have submitted version 1.1 with some corrections - mainly checking the symbol of orders - not to process orders of the symbol different from the chart thet EA is attached to).

From the chart snapshot you have sent it seems quite obvious that to achieve your goal parameters of my EA must be adjusted.

I am interested in catching long trends, so I have set default proportion ratio (the place between current and open price, where SL will be set) very low - 0.35 - to be sure, that 50% retracement will not trigger it.

But if you want to kinda use it for scalping - set it high - 70 - 80% (0.7 - 0.8). Seeing a log file or at least prices on the chart I could suggest parameters. Btw - was it back-testing?

 
denis_orlov:

Well, I have published your code with translated article for russian users.

Thank you for the permission.

'TradeProtector-1.0 Автоматический СтопЛосс и пропорциональный Трейлинг стоп'

Denis,

Thanks a lot for translating! I have submitted for proofreading an updated version (1.1). Could you attach it (when is made available) to the Russian mirror? Or at least give a link?

 

Marcool,


Thanks for your reply! "Meditate on this. I will" -yoda
What is "back-testing"? I've just added the openings code, to make your ea work in ea-tester to see what is it does in real. As you just said, it tries to minimalise the loss, that is nice. I also forgot to say a thank you for your code, i apologize.

S.

 
spockman:

Marcool,


Thanks for your reply! "Meditate on this. I will" -yoda
What is "back-testing"? I've just added the openings code, to make your ea work in ea-tester to see what is it does in real. As you just said, it tries to minimalise the loss, that is nice. I also forgot to say a thank you for your code, i apologize.

S.


Dear Spockman,

Alright, should be backtesting = testing in ea-tester :) - as opposed to testing in real life (for instance on demo account).
"Backtesting is a process, usually performed with aid of computers, by which traders try to estimate how financial instruments would have performed in the past had a particular mechanical trading system been employed to trade them." ( http://en.wikipedia.org/wiki/Backtesting ).

I am glad that someone is using it :-) No need to thank and apologize for not saying thank you :-))) But it's always a pleasure to deal with kind people... :-)

So I hope you can figure it out, how to adjust to get even better results? But finding the worst places to close the trade is a great feature for itself!!!
Having this, you will know when NOT to close your position, which is half-way to a success :-) "said that, lunch eat I will" - Marek

Reason: