Define value As Number = IndicatorValue(_PFEKeys(symbolIndex))
If (value < _oversoldValue) Then
If (_enableShorting And PositionExists(C_OPEN, symbolIndex, C_SHORT)) Then
BrokerMarket(C_BUY_TO_COVER,symbolIndex, 0, C_DAY, "Oversold.")
End If
If (Not PositionExists(C_OPEN, symbolIndex, C_LONG))
Define orderIndex As Number = BrokerMarket(C_BUY,symbolIndex, 0, C_DAY, "Oversold.")
BrokerSetStopLossPercent(orderIndex, _stopLoss, True)
BrokerSetTakeProfitPercent(orderIndex, _takeProfit, True)
BrokerSetTrailingStopLoss(orderIndex, _isPercent, _trailingStop)
End If
ElseIf (value > _overboughtValue) Then
If (PositionExists(C_OPEN, symbolIndex, C_LONG))
BrokerMarket(C_SELL,symbolIndex, 0, C_DAY, "Overbought.")
End If
If (_enableShorting And Not PositionExists(C_OPEN, symbolIndex, C_SHORT)) Then
Define orderIndex As Number = BrokerMarket(C_SELL_SHORT,symbolIndex, 0, C_DAY, "Overbought.")
BrokerSetStopLossPercent(orderIndex, _stopLoss, True)
BrokerSetTakeProfitPercent(orderIndex, _takeProfit, True)
BrokerSetTrailingStopLoss(orderIndex, _isPercent, _trailingStop)
End If
End If
|