Mariner Backtesting -MovingAverageTrailingStop

MovingAverageTrailingStop() 

MovingAverageTrailingStop()

Creates the instance.

 MovingAverageTrailingStop( md, IsBelow, Bars, BarSize, InitialStop, Offset, MinuteBarType, FieldName, MovingAverageType, ActiveBeginTime, ActiveEndTime )

Parameters:

Name Type Default Information
md object required ktg market data object
IsBelow boolean required used to determine if tracking from above or below the initial price
Bars integer required how many periods back
BarSize integer required size of bar
InitialStop float required initial stop price
Offset float required maximum offset from base value before updating the stop price
MinuteBarType string required string '1minute', '1minute.x', '1minute.t', '1minute.tx' ...REVIEW
FieldName string required bar field for calculating the moving average
MovingAverageType integer required 1 = simple - only value supported at this time
ActiveBeginTime MUTS required time of day the script begins monitoring.
ActiveEndTime MUTS required time of day the script ends monitoring.

Attributes:

Name Type Default Information
IsBelow boolean parameter used to determine if tracking from above or below the initial price
StopPrice float parameter InitialStop stop price
Bars integer parameter how many periods back
BarSize integer BarSize size of bar
Offset float parameter maximum offset from base value before updating the stop price
MinuteBarType string MinuteBarType string '1minute', '1minute.x', '1minute.t', '1minute.tx' ...REVIEW
FieldName string parameter bar field for calculating the moving average
MovingAverageType integer parameter 1 = simple - only value supported at this time
ActiveBeginTime MUTS parameter time of day the script begin monitoring.
ActiveEndTime MUTS parameter time of day the script ends monitoring.
IsActiveTime boolean False is the stop active
Distance float 0.0 different between last and stop price
BestInTrade float 0.0 best price in trade
DistanceHistogram float 1.0 histogram display for client feedback. between 0.0 - 1.0
SyntheticBarList list [] list of items used when `bar_size` isn't 1
MovingAverage float 0.0 calculated moving average
syn_bars object calculated `synthetic_bar(md, Bars, BarSize, MinuteBarType, FieldName)`

EvaluateStop()

Call to update the instance variables. Call method for checking instance variables.

 EvaluateStop( md )

Parameters:

Name Type Default Information
md object required ktg market data object

UpdateStopPrice()

Call to update the stop price. Can update and/or price and or offset.

 UpdateStopPrice( md, UpdateStopPrice, UpdateStopOffset )

Parameters:

Name Type Default Information
<updatestopprice< td=""> </updatestopprice<> float required desired stop price ```python if UpdateStopPrice != 0: self.StopPrice = UpdateStopPrice ```
UpdateStopOffset float required desired stop offset ```python if UpdateStopOffset != 0: self.Offset = UpdateStopOffset ```
Working Example:
 

Console