Guten Tag liebe PRT-Programmierer,
dies ist mein erster Post und ich stehe vor folgendem Rätsel: Die Strategie, die ich mir überlegt habe, soll sowohl auf der Long- als auch “spiegelverkehrt” auf der Short-Seite funktionieren.
Long wird auch genauso durchgeführt, wie beabsichtigt. Wenn ich jedoch die Vorzeichen umdrehe für die Short-Trades, werden Positionen nicht so wie beabsichtigt geschlossen, sondern viele Positionen bleiben einfach unzählige Bars lang offen, obwohl die Bedingungen zum Schließen längst eingetreten sind und die Postition geschlossen werden müsste.
Weiß jemand Rat?
Hier der Code für Long – Variablen: n=1;5 [1] ma=5;300 [5] (funktioniert tadellos):
DEFPARAM CumulateOrders = true
trend = close > Average[ma](close)
IF countofposition = 0 and trend THEN
BUY 1 share AT HIGH STOP
SET STOP %LOSS n
tp1= tradeprice
ENDIF
IF countofposition = 1 and trend THEN
BUY 1 share AT HIGH STOP
SET STOP %LOSS n
tp2= tradeprice
ENDIF
IF LONGONMARKET and countofposition = 1 and close > tp1 THEN
SELL 1 share AT Market
ENDIF
IF LONGONMARKET and countofposition = 2 and close > tp2 THEN
SELL 1 share AT Market
ENDIF
Und hier der Code für Short – Variablen: n=1;5 [1] ma=5;300 [5] (Positionen werden nicht geschlossen, zweite Position wird gar nicht erst eröffnet)
DEFPARAM CumulateOrders = true
trend = close < Average[ma](close)
IF countofposition = 0 and trend THEN
SELLSHORT 1 SHARE AT LOW STOP
SET STOP %LOSS n
tp1 = tradeprice
ENDIF
IF countofposition = 1 and trend THEN
SELLSHORT 1 SHARE AT LOW STOP
SET STOP %LOSS n
tp2 = tradeprice
ENDIF
IF SHORTONMARKET and countofposition = 1 and close < tp1 THEN
EXITSHORT 1 SHARE AT MARKET
ENDIF
IF SHORTONMARKET and countofposition = 2 and close < tp2 THEN
EXITSHORT 1 SHARE AT MARKET
ENDIF
COUNTOFPOSITION ist bei kurzen Aufträgen negativ. Ihre Bedingung sollte also geändert werden, um sie entsprechend zu testen.