Risk warning

All articles, strategies and indicators are just reflecting a single traders opinion and should be viewed as that.
I advice everybody to trade with a DEMO account!

Saturday, May 14, 2011

Protect your equity at all time : an emergency stop loss implementation.

Imagine you lose your internet connection while you got a strategy running? Did your strategy had an open position? Are you freaking out finding that phone number of your broker? Are they answering the phone? Why all that stress? Why not add some code to your strategy so in case this happens you can say : “ no problem I am pretty save”

Let's give an example how you can put a minimal protection in your coding.

In case you strategy buys a lot you put the following:

buy(lots);
stop_sell(lots,close[currentbar]-0.0050);

So at the same time the strategy is buying a lot you put a sell stop 50 pips below. Of course you can choose your own distance for the stop but remember this is an emergency stop. It shouldn't be triggered. So don't put it to close because it will interfere with the strategy.

When the strategy decides that it is time to close the position you also close the sell stop.

exitlong();
cancel_sell_stops();

This results that when the connection is lost or when the strategy has halted for any unknown reason. You always will have that emergency stop running minimizing the maximum loss you can have.

The reverse when the strategy sells some lots.

sell(lots);
stop_buy(lots,close[currentbar]+0.0050);

exitshort();
cancel_buy_stops();

Remember the important rules in trading:

Rule 1 : Protect your equity at all time
Rule 2 : NEVER forget rule 1
…....

No comments:

Post a Comment