CROSSTRIX PARA VISUAL CHART 6. Inherits StrategyPlugin Private period1 As Integer Private period2 As Integer Private period3 As Integer Private periodc As Integer Private stoploss As Double Private trixdata As Trix ''' ''' This method is used to configure the strategy and is called once before any strategy method is called. ''' Public Overrides Sub OnInitCalculate() Me.trixdata = New Trix(Me.Data, Me.period1, Me.period2, Me.period3, Me.periodc) End Sub ''' ''' Called on each bar update event. ''' ''' Bar index Public Overrides Sub OnCalculateBar(ByVal Bar As Integer) If (Not Me.IsLastDayBar) Then If (Me.GetMarketPosition() <> 0) Then If (Me.GetMarketPosition() = 1) Then Me.ExitLong(TradeType.AtStop, price:=Me.GetEntryPrice * (1 - Me.stoploss / 100)) Else Me.ExitShort(TradeType.AtStop, price:=Me.GetEntryPrice * (1 + Me.stoploss / 100)) End If End If If (Me.trixdata.Value() > 0 And Me.trixdata.Value(1) <= 0) Then Me.Buy(TradeType.AtMarket) ElseIf (Me.trixdata.Value() < 0 And Me.trixdata.Value(1) >= 0) Then Me.Sell(TradeType.AtMarket) End If End If End Sub CROSSTRIXWITHEQUITYCURVE PARA VISUAL CHART 6. Inherits StrategyPlugin Private period1 As Integer Private period2 As Integer Private period3 As Integer Private periodc As Integer Private trailstop As Double Private upperioddch As Integer Private dnperioddch As Integer ''' ''' strategy object based in CrossTrix strategy. ''' ''' Dim crosstrixstr As vcgstr_CROSSTRIX ''' ''' donchain channel object applied over CrossTrix strategy profit. ''' ''' Dim dchdata As DCH ''' ''' this trix object is the reference index for strategy rules. ''' ''' Dim trixdata As Trix ''' ''' flag value is used to activate or deactivate current strategy. ''' ''' Dim activate_str As Boolean ''' ''' This method is used to configure the strategy and is called once before any strategy method is called. ''' Public Overrides Sub OnInitCalculate() Me.crosstrixstr = New vcgstr_CROSSTRIX(Me.Data, Me.period1, Me.period2, Me.period3, Me.periodc, Me.trailstop) Me.dchdata = New DCH(Me.crosstrixstr, Me.upperioddch, Me.dnperioddch) Me.trixdata = New Trix(Me.Data, Me.period1, Me.period2, Me.period3, Me.periodc) Me.activate_str = True End Sub ''' ''' Called on each bar update event. ''' ''' Bar index Public Overrides Sub OnCalculateBar(ByVal Bar As Integer) '--- Activate/Deactivate strategy --- If Me.dchdata.Value(0, 3) <> CDbl(ErrorCodes.NullValue) And Me.dchdata.Value() <> CDbl(ErrorCodes.NullValue) Then If (Me.crosstrixstr.Profit <= Me.dchdata.Value(0, 3)) Then Me.activate_str = False ElseIf Not (Me.activate_str) Then Me.activate_str = (Me.crosstrixstr.Profit >= Me.dchdata.Value()) End If End If '--- Current strategy rules -- If (Me.activate_str) Then If (Not Me.IsLastDayBar) Then If (Me.GetMarketPosition() <> 0) Then 'Me.ExitTrailingStop(Me.trailstop) If (Me.GetMarketPosition() = 1) Then Me.ExitLong(TradeType.AtStop, price:=Me.GetEntryPrice * (1 - Me.trailstop / 100)) Else Me.ExitShort(TradeType.AtStop, price:=Me.GetEntryPrice * (1 + Me.trailstop / 100)) End If End If If (Me.trixdata.Value() > 0 And Me.trixdata.Value(1) <= 0) Then Me.Buy(TradeType.AtMarket) ElseIf (Me.trixdata.Value() < 0 And Me.trixdata.Value(1) >= 0) Then Me.Sell(TradeType.AtMarket) End If End If Else If (Me.GetMarketPosition = 1) Then Me.ExitLong(TradeType.AtMarket) ElseIf (Me.GetMarketPosition = -1) Then Me.ExitShort(TradeType.AtMarket) End If End If End Sub