Hallo,
ich wollte gerne meine Positionsgröße darauf einstellen wie meine Strategie in Bezug auf Strategyprofit gerade läuft. Befindet sich die Strategie in einer UP-Phase(über einem SMA200 zum Beispiel) möchte ich die Positionsgrößen erhöhen, befindet sich die Strategie in einer Drawdownphase möchte ich die Positionsgröße auf einen Minimalwert setzen. Wie genau kann ich das programmieren?
also:
Strategyprofit > SMA200 = größere Position
Strategyprofit < SMA200 = kleinere Position
Da ist er.
Was bedeutet STRATEGYPROFIT> Sma200? Ich werde erhöhen, wenn der Gewinn steigt, und ich werde dominieren, wenn er sinkt.
Sie entscheiden, wie viel Sie erhöhen oder verringern möchten, die beiden Werte können unterschiedlich sein, Sie können um 2 erhöhen, aber um 3 verringern (ohne jemals das Minimum zu unterschreiten):
ONCE LotSize = 1 //starting number of lots/contracts
ONCE MinLots = 0.5 //minimum lot size required by the broker
ONCE Rise = 1 //numebe of lots to increment
ONCE Fall = 1 //number of lots to decrement
IF StrategyProfit > StrategyProfit[1] THEN
LotSize = LotSize + Rise
ELSIF StrategyProfit < StrategyProfit[1] THEN
LotSize = LotSize - Fall
ENDIF
LotSize = max(MinLots,LotSize)
IF MyLongConditions THEN
BUY LotSize CONTRACTS AT MARKET
ENDIF
IF MyShortConditions THEN
SELLSHORT LotSize CONTRACTS AT MARKET
ENDIF
Ok, das sieht gut aus. Danke.
Ich dachte eigentlich an einen Mittelwert über dem Strategyprofit, aber diese Variante gefällt mir auch sehr.
Kann man noch eine Begrenzung einbauen? Position maximal?
Ich habe das Maximum hinzugefügt und ich habe auch die Version mit dem Durchschnitt bei 200 Perioden erstellt:
ONCE LotSize = 1 //starting number of lots/contracts
ONCE MinLots = 0.5 //minimum lot size required by the broker
ONCE MaxLots = 999 //999 max lots allowed (to be also set in AutoTradung)
ONCE Rise = 1 //numebe of lots to increment
ONCE Fall = 1 //number of lots to decrement
IF StrategyProfit > StrategyProfit[1] THEN
LotSize = LotSize + Rise
ELSIF StrategyProfit < StrategyProfit[1] THEN
LotSize = LotSize - Fall
ENDIF
LotSize = min(MaxLots,max(MinLots,LotSize))) //check both Maximum and Minimum
IF MyLongConditions THEN
BUY LotSize CONTRACTS AT MARKET
ENDIF
IF MyShortConditions THEN
SELLSHORT LotSize CONTRACTS AT MARKET
ENDIF
ONCE LotSize = 1 //starting number of lots/contracts
ONCE MinLots = 0.5 //minimum lot size required by the broker
ONCE MaxLots = 999 //999 max lots allowed (to be also set in AutoTradung)
ONCE Rise = 1 //numebe of lots to increment
ONCE Fall = 1 //number of lots to decrement
AvgStrategy = average[200,0](StrategyProfit)
IF StrategyProfit > AvgStrategy THEN
LotSize = LotSize + Rise
ELSIF StrategyProfit < AvgStrategy THEN
LotSize = LotSize - Fall
ENDIF
LotSize = min(MaxLots,max(MinLots,LotSize))) //check both Maximum and Minimum
IF MyLongConditions THEN
BUY LotSize CONTRACTS AT MARKET
ENDIF
IF MyShortConditions THEN
SELLSHORT LotSize CONTRACTS AT MARKET
ENDIF
Du bist der Größte. Danke.