SDM Trading Strategy Definition

Any trading strategy needs the following three elements:

Warmup

(pre entry)
Logic to describe when to go long or short, the position entry conditions
executed on each bar, In the SDM system we use the following "Warmup level":
0 completely cold
1 - 90 different degrees of getting closer to a long entry condition
95 Long Position Entry at pre-calculated fixed limit order price
the system will be waiting that the market comes to your price
up to a maximum waiting period you can define
100 Long Position Entry at market
-1  to -90 different degrees of getting closer to a short entry condition
-95 Short Position Entry at pre-calculated fixed limit order price
the system will be waiting that the market comes to your price
up to a maximum waiting period you can define
-100 Short Position Entry at market
Example:
Logic:
;------ Calculate CCI indicator (14 bars, 9 Avg) ---------
$CCI = CCI(14,9)

Strategy:
;------ Check if we are in our time range ----------------
;------ 9:45:00 to 12:00:00 and 13:05:00 to 15:20:00 -----
if NoRange(Time,94500,120000,130500,152000)
   exit
endif

;------ Make sure we are flat ----------------------------
if NoRange(WarmupStatus,-94,94)
   exit
endif

;------ Check if CCI indicator has a value ----------------
;------ (1st bars don't have yet a CCI Value) -------------
if $CCI <> Empty
   WarmupStatus = 20
   if $CCI < -80
      WarmupStatus = 20
      if $CCI < -100
         PositionEntry("Long")     ; WarmupStatus automatically set to 100
         PlaySound("CashRegister")
      endif
   endif
endif
Entry

(at entry once)
Logic to describe the standard position exit conditions
called only once when a new position opened
Example:
;---------- POSITION ENTRY ------------------------
Entry:
PositionExit("Target",0,2.5)
PositionExit("Stop",0,2)

Set the target 1.5 points away from the actual position entry price (longs above, shorts below) and
the stop out price at 2.0 points away from the entry price (longs below, short above)
Exit

(while long/short)
Logic to describe custom position exit conditions 
called only on each bar close when you are long or short
Example:
;---------- POSITION EXIT LOGIC -------------------------
Exit:
;------ LONG -----------------
if PositionDirection > 0
   ;--- If we have more than 2 pts gain ----
   ;--- set stop out to break even -0.25 ---
   if PositionMaxGain >= 2.25
      $PrcStopG = PositionEntryPrice - 0.25
      if $Stop < $PrcStopG
         PositionExit("Stop",$PrcStopG,0)
      endif
   endif

   ;--- If CCI is larger than 70 - exit immediatelly at market ---
   if $CCI > 70
      PositionExit("ExitNow","90/200","CCI")
   endif
endif

SDM Position Management Functions

$Stop = GetPositionExit([nExitType]) Get Stopout level of specified ExitType (default = closest to Entry)
1 Target
2 StopOut
3 Time/PosAge
4 SAR
5 Notch
6 DayEnd
7 ExitNow
8 Stages
9 Regression
PositionAgeSec Age of current position (Seconds from entry)
PositionAgeDays Age of current position (Days from entry)
PositionDirection Indicates the current Position status:
0 Flat
1 Last Long Position closed
2 Long Position is active
-1 Last Short Position closed
-2 Short Position is active
PositionEntry("Dir"[,Entry[,Wait[,Tar[,Stop]]]) Position Entry (If CheckPoints enabled new CheckPoint):
"Dir" Position Entry Direction "Long" or "Short"
Entry Limit Order Entry Price you want to get (if 0 or default = close)
Wait Max Time to wait for a catch in seconds
(If an entry price was specified)
If negative number of bars to wait
Tar Target price distance from entry price (0=none)
Stop Stop out Price distance from entry price (0=None)
PositionExit("Type",par1[,par2...]]) Define a position exit condition in the "Entry" logic section or module:
Stop Stop out at specified (relative or absolute)
Example Stop at absolute price
PositionExit("Stop",850,50)

or Stop out at a relative price distance from entry price
PositionExit("Stop",0,10.0)    - Stop out 10$ away from the entry price

Target Close with a a gain (relative or absolute)
Example: Set Target at absolute price
PositionExit("Target",850,50)

or set target price a specified distance from entry price
PositionExit("Target",0,10.0)    - Target at 10$ above entry price (if long)

DayEnd Exit (intraday) position when the day ends (default 15:55:00)
Example: PositionExit("DayEnd",155000)
Notch Trailing Stop which gets "notched" up with the maximum gain
par1=Notch Factor
par2=Notch Distance
Example : PositionExit("Notch",0.9,2,TypicalPrice)
Trail stop with an initial distance of 2.0 Points and follows a little slower
i.e. on 10 point gain the stop out distance is:
10 x 0.9 = 9 + 2 =11points
Regression Apply regression on trailing scope window:
Par1 Offset applied to Trendline (Long=-, Short=+)
Par2 Scope in number of bars to look back (0=all since Entry)
Default = 20 bars, negative = duration in Seconds
Par3 Input Type Default=Low(Short), High(Long) (High,Low,HighLow,HighLowClose,Close,Avg,HighLowClose3)
Par4 Polynominal Order (Default=Linear Regression)
(1=Linear Regression, 2=parabolic, 3=cubic...) 
Par5 Scope Buffer in Bars (default=0) (Negative=Seconds)
ExitNow par1=Exit Sequence instructions: Dur/PriceLocation
Dur Duration in Seconds
PriceLocaction Long Position:
100=Ask, 50=between Bid/Ask, 0=Bid, 200=Market
Short Position:
100=Bid, 50=between Bid/Ask, 0=Ask, 200=Market

Example for Long Position:
PositionExit("ExitNow","4/100;3/50;90/200")
For 4 Seconds try to sell at current Ask, then
for 3 seconds try to sell between bid/ask, then
sell at Market

SAR  
Time Exit when position has reached specified Age (in Seconds)
PositionMaxGain Maximum Gain in Points from Entry
PositionMaxLoss Maximum Loss in Points from Entry (always positive value or 0)
PositionPoints Current Gain/Loss in points from Entry Price
PositionStatus = CheckPositionExit() Check if any of the defined standard position exits triggered
Evaluates all defined position exits and returns a normalized value
PositionStop Current Stop out price
PositionTarget Current Position Target Price
WarmupStatus Current level of your Warmup 
CheckPoint("Dir"[,Entry[,Back]]) Instead of a position entry - create a check point during back testing.
Checkpoints allow you to execute instant statistical analysis,
applying custom filter conditions and checking the average Position Gain/Loss
over time since the entry (normalized to point distance from various entry prices)
(Make sure Checkpoints are enabled in Setup!)
(You can also create checkpoints with PositionEnrty()) 
"Dir" Position Entry Direction "Long" or "Short"
Entry Entry Price to be catched (if 0 or default = close)
Back Number of Seconds back (default current time at end of current bar)
   

 

 © Copyright 1998-2003, Burkhard Eichberger, Professional Software Solutions
All Rights Reserved Worldwide.