BREAKEVEN STOP addition to Volatiltity System

Questions about MultiCharts and user contributed studies.
khalaad
Posts: 323
Joined: 07 Jan 2007
Location: Lahore, Pakistan
Has thanked: 64 times
Been thanked: 57 times

BREAKEVEN STOP addition to Volatiltity System

Postby khalaad » 02 Mar 2007

I wish to add BREAKEVEN STOP to Welles Wilder's Volatility System and have the following code, which compiles successfully, the buy (long) and sell short signals work, but the STOP is not implemented:

{---- Long Position ---- }
if close crosses above (lowest(close,7)[1] + AvgTrueRange(7)[1] * 3) then buy this bar at close;
if MarketPosition = 1 and close crosses above (EntryPrice + AvgTrueRange(7) * 2) then setstoploss (entryprice + 0.5);
{ ---- Short Position ---- }
if close crosses below (highest(close,7)[1] - AvgTrueRange(7)[1] * 3) then sell short this bar at close;
if MarketPosition = -1 and close crosses below (EntryPrice + AvgTrueRange(7) * 2) then setstoploss (entryprice - 0.5);

Any help would be greatly appreciated.

Thank you.

KHALAAD

User avatar
Stanley Miller
Posts: 556
Joined: 26 Jul 2005
Has thanked: 3 times

Postby Stanley Miller » 06 Mar 2007

Where did you find this code? It uses SetStopLoss reserved word incorrectly.

Fist of all, this reserved word is used to specify the amount you are willing to lose per position or per contract/share. You are trying to specify the price level.

Also, it should be used with SetStopContract or SetStopPosition.

Example
You are long 10 shares and the entry price is 52. To exit your long position when you’re down $2/per contract or share, write:

SetStopContract ;
SetStopLoss(2) ;

Additional Example
You are long 500 shares, and the entry price is 12. To exit your long position when you’re down $1000 for the entire position, write:

SetStopPosition ;
SetStopLoss(1000);

In this case, when the price reaches 10, you are exited from your long position (500 x $2 = 1000).

klalaad

BREAKEVEN STOP addition to Volatility System

Postby klalaad » 06 Mar 2007

Stanley,

The entry code was very kindly written by you; the exit is my very own attempt!

What I am trying to add to the code you wrote is to put a BREAK-EVEN stop after a position becomes favourable by a certain number of ATRs .

I am interested in futures. Because futures prices for different contracts are written differently, I would appreciate how to correctly write prices for stops as number of TICKS.

Moreover, guidance on how to write a big POINT would be greatly appreciated.

Thank you.

khalaad


Return to “MultiCharts”