SDM Language Indicators

The indicators and logic sections are all defined in the *.sdc files in the C:/SDM/Definitions folder.
The *.sdc (SDM Chart file) contains first the Layout definition for the chart:
[Window1]
....

[Window2]
...

Logic:
;---- Define all your indicators
$CCI = CCI(14,9)
...

Strategy:
;---- Trading Strategy Logic for position entries

Entry:
;---- Define your Position Exits

Exit:
;---- Define custom exit conditions

SDM Language Sections

The SDC (SDM Chart) file contains following sections: 

Layout Defines the Chart Layout
From beginning to keyword "Logic:"
Indicator Section Defines and calculates all your inidicators
From "Logic:" to the next keyword (i.e. "Strategy:" or "Entry:")
Strategy Section Defines the logic for your trading strategy - when to go long or short
From "Strategy:" to next keyword (i.e. "Strategy:" or "Entry:")
Entry Section Defines all standard Position Exits, called once when a new position opened
From ":Entry:" to next Keywordk (i.ie. "Exit" or end of FIle)
Exit Section Defines any custom exit conditions, called on each bar as long as you are not flat
From "Exit:" to end of file

Comments start with a semicolon in the first column.
You can declare a variable instantly in the code, by using '$' and the variable name.

SDM Conditions (IF/ELDE/ENDIF)
Conditions are defined  with the IF/ELSE/ENDIF instructions:
If {Cond}
   Statements if TRUE ...
[else]
   Statements if FALSE ...
endif

The ELSE Section is optional, but ENDIF is required, IF's can be nested.

Conditions are defined as:
Obj1   Operand  Obj2

The following conditional Operands are available:

< Less than
<= Less or eqaul
= Equal
<> Not Equal
>= Greate or Equal
> Greater than



SDM Objects
The following objects are available:

$Var Current Value of the Variable $Var
Constant 10.0 or -3
Empty indicates an Object to which no value has not yet been assigned
Flexible Constant &ConstantName:DefaultValue&
Example:
if $CCI < &MinCCIValue:-100&
Flexible Constants can be varied during the back testing process.
In the chart and automated trading they use the defined default value
Ranges can define default values with the '~' delimiter:
if NoRange($CCI,&RangeCCI:~100~120&)
Unilateral Functions The following unilateral functions are available in IF conditions:
Range(Obj,Min,Max) TRUE if the value of Obj is between Min and Max (inclusive)
Range(Obj,Min1,Max1,Min2,Max2) TRUE if the value of Obj is between Min1 and Max1 (inclusive)
or Min2 and Max2 - you can define up to 5 Min/Max pairs
MakeInvert(Obj) Return the Inverted value of Obj
MakeNegative(Obj) Make the value of Obj negative
MakePositive(Obj) Make the value of Obj positive
   
NoRange(Obj,Min,Max) TRUE if the value of Obj is not between Min and Max (inclusive)
NoRange(Obj,Min1,Max1,Min2,Max2) TRUE if the value of Obj is not between Min1 and Max1 (inclusive)
and not between Min2 and Max2 - up to 5 Min/Max pairs
   
   


Standard Objects See below for the list of the SDM Standard Data Objects
Example: Low = Current Bar Low, Close= Current Bar Close, Time=Current Time
Position Objects The following Position related Objects are available:
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
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() 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 
Timer(n) Value describing the state of Timer {n}:
>0 Age since start - or restart in Seconds
-1 Just expired in this bar
-2 Expired in previosu bars or never activated

Assigning Values to Variables

To assign a value to a variable use:
$Var = Obj1  DataOp Obj2    or
$Var = Func(Par1...)

The following Data Operands are available:

+ or Add Obj1 + Obj2
- or Sub Obj1 - Obj2
* or Multiply Obj1 * Obj2
/ or Divide Obj1 / Obj2
% or Mod Modulo of Obj1 into Obj2 (Obj1 % Obj2)

SDM Studies
(Scope can be in number of Bars or if negative in Seconds)

BollUp(Scope,StdDev,Obj,["Style")
BollDown(Scope,StdDev,Obj,["Style")
BollWidth(Scope,StdDev,Obj,["Style")
BollWidthPercent(Scope,StdDev,Obj,["Style")
Bollinger Band Calculations:
Scope Scope in Bars (or Seconds if negative)
StdDev Standard Deviations (can be fractional 2.1)
"Style" can be "Exp" for exponential Avg (default is simple avg)
BollUp Upper Bollinger Band Price
BollDown Lower Bollinger Band Price
BollWidth Bollinger Band Width as Amount
BollWidthPercent Bollinger Band Width as Percent against the median
CCI(Scope,Smooth,Obj,Show) Commodity Channel Index (Show values starting at bar, 0=on Scope)
CountSame("Spec") Count same directional bars:
Adverse=n  Number of adverse bars allowed (default =1)
MinMove=x Minimum open/close difference for calc (default 0.01)
BarCounter=f  Return number of bars (f is dividing factor , default=1)
End Return only when accumulation ended
Examples
CountSame(^Adverse=3/MinMove=0.02^)
detects accumulations, allowing up to 3 adverse bar with a min of 0.02$ price change, returns accumulative value

CountSame(^BarCounter=3/End^)
Returns number of bars in last accumulation, only when the accumulation just ended
Dividing the number of bars by 3

$Pivots = DeltaInit($PivotMin,$PivotMax) Initialize Delta Calculations
$PivotMin/Max are the Pivot Low/High to be analyzed
DeltaCalc($Pivots,"Cmds",nScope,[nLast]) Calculate Deltas:
$Pivots Variable from DeltaInit (see above)
"Cmds" Processing commands separated by '/':
Angle Calculate Angle($/Hr) between pivots
Avg Calc Average of last nScope Deltas
Dur Calculate Duration(Sec) difference between pivots
Percent[Fac] Calc Percent change (reference is Open of first bar)
(Multiply percent by factor "Fac")
Price Calculate Price difference between pivots
Verbose[n] Set Verbose level n
nScope Number of Deltas to calculate for Avg
nLast Optional factor of how many times the current delta should be included into the Avg (default = 1)
EMA(Scope,Obj) Exponential Moving Avgerage, Scope=1 to 1000, Obj=$Var etc
FVE(Scope[,Fac[,PrcObj[,VolObj[,nStyle]]]]) Finite Volume Elements (FVE) Study
Scope Scope of Study (default 21)
Fac Threshold factor in % of Closing Price (default 0.3%)
If negative actual price, not percent of close
PrcObj Object for Price difference Calc (default: TypicalPrice)
VolObj Object for Volume (default: Volume)
nStyle 1 if you want to neglect the small price changes from the overall Average (default use all values)
GetAngle(Obj[,Fac,[Bar]]) Calculate the Angle (Difference between points)
Obj Object to get the angle from
Fac Factor to be applied to the angle:
>0 multiply the difference by Fac, Example: GetAngle($Prc,100)
0 (Default) extrapolate the change to a one hour period
<0 extrapolate the change per hour and multiply by -Fac
Bar If specified the reference index to get angle from
(default previous bar)
LineOp(Obj,^Type/Flag1/...^,Arg1,Arg2..)
Line Operations:
Pivot Detect a Pivot - the following additional attributes can be used:
High or Max or + Find The Max/High Pivot points
Low or Min or - Find The Min/Low Pivot points
Positive Filter out only Pivots with a positive value
Negative Filter out only Pivots with a negative value

Arg1 =  Scope (default 2 points left and right)
Arg2 = Min Percent difference between pivot points (Default 0=none)
Arg3 = right hand scope (default = Arg1 scope)
Example: LineOp($Ema,^Pivot/High^,3,0.6)
High Pivots with 3 points left and right lower and at least 0.6% value change

Accu Process Accumulations - the following additional attributes can be used:
Age Return Age in Seconds (Arg1 must be "IntervalSec")
Avg Return Average of Accumulated Sequence
Cnt Return Number of bars in accumulation
Diff Difference obetween Accumulation Begin Values
Last Last Accumulated Sum
Sync  
Trigger Check Accumulation end: +1=up, -1=down
(nothing) Accumulated Sum

Obj = Data Object to Accumulate on
Arg1 = Reference Value (Constant or other Object)
Arg2 = Minimum Value at cross over

ZeroCross Return value of obj if zero is crossed (otherwise return Empty).
The following attributes are available
IncludeZero Include also the zero value itself as crossed
Positive Only crossover from negative to positive
Negative Only crossover from positive to negative 
MA(Scope,Obj) Regular Moving Avgerage, Scope=1 to 1000, Obj=$Var etc
MaxChange({+|-}{$|%|#} , Obj [,nScope[,Ref]])
Calculate the Maximum Change in Percent:
+|- += Max Change Up
- = Max Change Down
%=Percent, $=Amount, #=Count Bars
Obj Value for which to find the Change
nScope Number of Bars back to check for the biggest change (default=10)
Ref Reference Value to compare against (default=current Close)
MaxValue({+|-} , Obj [,nScope[,Ref]]) Find the Maximum Value withjn specified scope
+|- += Max Change Up
- = Max Change Down
%=Percent, $=Amount, #=Count Bars
Obj Value for which to find the Change
nScope Number of Bars back to check for the biggest change (default=10)
MFI(Scope,Smooth,Obj) Money Flow Index
Percent(Obj,Ref[,Factor]) Calculate the percent change between Obj and Ref
If Factro speicfied multiply percent by it (default Factor=1)
PosInChannel(Obj,Max,Min) Return the normalized position of the of Obj within the Max-Min Range as%
+100 Value = Max
0 Value = (Max + Min)/2 exactly between Max and Min
-100 Value = Min
RegChaUp(Obj,Scope[,Delay]) Calc linear Regression base on values in Obj of the recent 'Scope' bars
and a delay of 'Delay' bars (default 10) and find upper touching line
RegChaDn(Obj,Scope[,Delay]) Calc linear Regression base on values in Obj of the recent 'Scope' bars
and a delay of 'Delay' bars (default 10) and find lower touching line
RegChaAngle(Obj,Scope[,Delay[,DIst]]) Calc the angle (in points per hour) of linear Regression base on values in
Obj of the recent 'Scope' bars and a delay of 'Delay' bars (default 0)
Use 'Dist' bars for the difference calculation (default current to bar -10)
RoundDown(Prc,Inc) Round Price down based on Inrement "Inc"
Example: RoundDown(800.12,0.25) = 800.00
RoundUp(Prc,Inc) Round Price up based on Inrement "Inc"
Example: RoundUp(800.12,0.25) = 800.25
RSI(Scope,Smooth,Obj[,"Attr"]) Relative Strength Index of last "Scope" bars using Smoothing (0=none) for Obj
"Attr" can specify additional attributes separated by '/' (Attr1/Attr2..)
Simple Use simple miving avg for smoothing instead of default Exponetial
Stretch{n} Stretch RSI around the mid point by n percent
Shrink{n} Shrink RSI around the mid point by n percent
PlusMinus Use RSI Range -100 to +100 instead of default 0 to 100;
Midpoint is then 0 instead of 50, 70/30 becomes +40/-40
(Makes more sense to have a polar indicator)
   
Stoch(Scope,Smooth,Obj)  or
Stochastic(Scope,Smooth,Obj)  or
Stochastic Range of last "Scope" bars using Smoothing (0=none) for Obj
StochAll(Obj,Smooth or
StochasticAll(Obj,Smooth)
Stochastic Study for entire Intraday Range
TSI(ScopeShort,ScopeLong,Obj) True Strength Index
ScopeShort = ShortTerm scope (e.g. 5)
ScopeLong  = LongTerm scope (e.g. 40)
Obj                = Price (e.g. Close, or HighLowClose)
ZScore(Scope,StdDev,Obj) Normalized Bollinger Bands
Scope Scope in Bars (or Seconds if negative)
StdDev Standard Deviations (can be fractional 2.1)
"Style" can be "Exp" for exponential Avg (default is simple avg)

SDM Standard Data Objects

Open Opening price of this bar
High High price within this bar
Low Low price within this bar
Close Closing price of this bar
AvgPrice Average Price of all ticks of this bar
Volume Volume of this bar
Date Date of this Bar (YYYYMMDD)
TimeStart Starting time of the Bar (HHMMSS)
TimeStartSec Starting time of the Bar (Number of Seconds from midnight)
Time Ending time of the Bar (HHMMSS)
TimeSeconds Ending time of the Bar (Number of Seconds from midnight)
BarCounter Bar Number (starting at 0 for the first Bar)
HighLow (High + Low)/2
HighLowClose
TypicalPrice
(High + Low + Close)/3
HighLowClose3 (High + Low + 3xClose)/5
Close121 (Close + 2xClose[-1] + Close[-2])/4
Close1221 (Close + 2xClose[-1] + 2xClose[-2] + Close[-3])/6
TodayBarCounter BarSequence Number relative to the beginning of the day (0=first bar on current date)
Typical121 (TypicalPrice + 2xTypicalPrice[-1] + TypicalPrice[-2])/4
Typical1221 (TypicalPrice + 2xTypicalPrice[-1] + 2xTypicalPrice[-2] + TypicalPrice[-3])/6
TrueRange Welles Wilder described these calculations to determine the trading range for a stock or commodity.
True Range is defined as the largest of the following:
  • The distance from today's high to today's low.
  • The distance from yesterday's close to today's high.
  • The distance from yesterday's close to today's low.

Wilder included price comparisons among subsequent bars in order to account for gaps in his range calculation. The raw True Range is then smoothed (a 14-period smoothing is common) to give an Average True Range (ATR).  The True Range can be smoothed using a variety of moving average types, including Simple, Exponential, Welles Wilder, etc.
ATR measures a security's volatility.  It does not indicate price direction or duration, rather the degree of price movement.  Average True Range can be interpreted using the same techniques that are used with the other volatility indicators.
Wilder states that high values of ATR often occur at market bottoms following a sell-off. Low ATR values are often found during extended sideways or consolidation periods.

TickSkew Normalized position of last tick within Bid/Ask: 100=Ask, 0=Bid, 50=between Bid/Ask
TickDir TickDirection: 1=Up, -1=Down
TickDirVolume TickDirection: 1=Up, -1=Down multiplied by the Volume
TickSpeed Number of ticks per second traded
TickWind Avg tick position within Bid Ask (Bid=0 Ask=100, in  between=50)
DayHigh Highest Price in the day
DayLow Lowest Price in the day
DayOpen Opening price of today
DayClose Closing price of today
BidAsk(nType) Get Bid/Ask Size related derivations, based on nType: (Ratio=100 *(Ask/Cnt - Bid/Cnt)
1 Bid/Ask Ratio Avg
2 Avg Bid+Ask Volume
3 Bid/Ask Ratio Avg (accumulated on each tick)
4 Ration of Up/Down Ticks
5 Counter of ticks in this bar
6 Combine 3 and 4



Available SDM Special Functions

EnveleopeHigh(ScopeS,ScopeL) ScopeS     = Short term scope (default 6 bars)
ScopeL     = Long term scope (default 20 bars)
ExpandedScope(nDur,nBack,Seq[,"Sym"]) Load expanded scope into current stream
nDur Duration in Seconds (if < 5 = Ticks)
nBack Number of back days to be loaded
nSeq Sequence Number for this parallel stream(1...5)
"Sym" Symbol to be laoded (default = current symbol)
ExpandedStudy{Seq}:Study(par1...) Calc "study" in paralellel Stream # Seq
Study("StudySpec"[,nBack) Calculate the specified study (see below) (nBack = values back)
Timer(nID,nDur) Initiate a Timer with the specified ID and Duration(nDur in Seconds)
Timer(nID) returns the timer elapsed since initiation, -1=expired, -2=just expired
Example:

if Range(Time,100000,123000)
   Timer(3,180) ; Start timer for 180 Seconds(3Minutes)
endif
if Timer(3) >= 0
   ; Timer is still running
endif