Help with Stop Loss

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Help with Stop Loss

Postby Laurent » 18 Dec 2011

Hello,

I do not understand the code of the Percent Stop Loss provided in MultiCharts.

Let's see the code of Percent Stop LX ;)
What I understand is that code is used to exit from a long entry.

Code: Select all

inputs: StopLossPct( .05 ) ;

SetStopShare ;
if MarketPosition = 1 then
SetStopLoss( EntryPrice * StopLossPct )
else
Sell ( "PctStopLX-eb" ) next bar at Close * ( 1 - StopLossPct ) stop ;
So... let's start:
if MaketPosition = 1 then // Indicates a long position in the doc
SetStopLoss( EntryPrice * StopLossPct ) // We set a stop at the Entry Price * StopLossPct

Hmm let's take an example.
I have bought a share at 100$ (I'm long).
I set a stop by default at 100$*0.05 = 5$??? WTF? :)

It should be EntryPrice * (1 - StopLossPct) = 100$ - (1-0.05) = 95$
What am i missing?

Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Re: Help with Stop Loss

Postby Laurent » 18 Dec 2011

Ok, it seems relative to the entry and to the position (short/long).

So if in my system I put the following signals:

// SX - Stop percentage
Inputs:
PercentageLoss( 0.05 ) ;

Var:
LossLimit ( 0 );

SetStopPosition;

if MarketPosition = -1 then
begin
LossLimit = EntryPrice * PercentageLoss;
SetStopLoss(LossLimit);
end;
and
// LX - Stop percentage
Inputs:
PercentageLoss( 0.05 );

Var:
LossLimit ( 0 );

SetStopPosition;

if MarketPosition = 1 then
begin
LossLimit = EntryPrice * PercentageLoss;
SetStopLoss(LossLimit);
end;
Is it ok? I want them to protect me from X% of loss after a short sell and X% of loss after a long buy?


Return to “User Contributed Studies and Indicator Library”