Liebe Freunde,
habe einen automatische Positionseröffnung samt Stopp in ProRealTime programmiert. Wenn nun der Trade +40 DAX-Punkte ins Plus gelaufen ist, möchte ich den Stopp auf den Einstandspreis nachziehen.
Beispiel:
Eröffnungskurs 12.000
Stopp 33
bei Kurs von 12.040 Stopp ändern auf 12.000
Wer kennt die Lösung?
mfg
sl=33
if close-positionprice>=40 then
sl=close-positionprice
endif
set stop ploss sl
So z.B..
Thank You so much,
I tried it but it stops still at the old stop
Here the complete program an DAX 20170403
// Start Long at 080000, close at 17:30h, SL18, TP180, newStopOver40
// Code-Parameter
DEFPARAM CumulateOrders = False // cumulation of positions deactivated
DefParam FlatAfter = 173000 // close all orders and positions at 17:30
// opening
c6 = (CurrentTime = 080000)
// condistion of opening Long
IF c6 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Targets
SET TARGET PPROFIT 180
// Stop1
SET STOP PLOSS 18
// new stop over +40
sl=18
if close-positionprice>=40 then
sl=close-positionprice
endif
set stop ploss sl
whats wrong?
many thanks
also a 2.Variation uses the first stopp:
// Start Long at 080000, close at 17:30h, SL18, TP180, newStopOver40
// Code-Parameter
DEFPARAM CumulateOrders = False // cumulation of positions deactivated
DefParam FlatAfter = 173000 // close all orders and positions at 17:30
// opening time
c8 = (CurrentTime = 080000)
// conditions of opening Long
IF c8 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Targets
SET TARGET PPROFIT 180
// Stop1
SET STOP PLOSS 18
// new stop over +40
if high-positionprice>=40 then
SET STOP LOSS high-positionprice
endif
Please speak German in English Forums and >> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
Nimm in deiner ersten Variante die Zeile mit set stop ploss 18 weg, die ist ueberfluessig. Wenn’s dann immer noch nicht geht, solltest du mal graph benutzen, um zu gucken wie sich deine SL verändert.
den SL 18 brauch ich aber, wenns tatsächlich gleich zu Beginn ins Minus läuft
habs aber trotzdem versucht und jetzt stoppt er mich bei -40 aus!!
Also: die folgende Anweisung stoppt bei -18
// Code-Parameter
DEFPARAM CumulateOrders = False // cumulation of positions deactivated
DefParam FlatAfter = 173000 // close all orders and positions at 17:30
// opening
c6 = (CurrentTime = 080000)
// condistion of opening Long
IF c6 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Targets
SET TARGET PPROFIT 180
// new stop over +40
sl=18
if close-positionprice>=40 then
sl=close-positionprice
endif
set stop ploss sl
Habs weiter vereinfacht und statt “Close” “High” genommen (weil ja Close unter 40 sein kann obwohl high schon drüber wwar. Es bleibt aber beim Stopp -18
// Code-Parameter
DEFPARAM CumulateOrders = False // cumulation of positions deactivated
DefParam FlatAfter = 173000 // close all orders and positions at 17:30
// condition of opening Long
IF CurrentTime = 080000 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Targets
SET TARGET PPROFIT 180
// new stop over +40
sl=18
if high-positionprice>=40 then
sl=high-positionprice
endif
set stop ploss sl
glaube ich habs: potitionpreis ist laut Handbuch nicht der Eröffnungskurs sondern der Durchschnittspreis der Position (und der erreicht tatsächlich nicht 40 über Einstand – ich brauche also statt positionprice den Eröffnungskurs und der heißt …………????
der Eröffnungskurs laut Handbuch dürfte der “TRADEPRICE” sein, bringt aber auch keine Verbesserung. Weiter bei -18 ausgestoppt obwohl 49 im Plus
Alexander,
Du drueckst dich wirklich recht schwerverständlich aus. tradeprice und positionprice geben dasgleiche Resultat, da deine Position nicht kumuliert ist. Das ist egal. Das Problem wird dadurch verursacht, dass du stop loss ja jede Candle wieder auf setzt. Das musst du verhindern. So z.B.:
// Code-Parameter
DEFPARAM CumulateOrders = False // cumulation of positions deactivated
DefParam FlatAfter = 173000 // close all orders and positions at 17:30
// opening
c6 = (CurrentTime = 080000)
// condistion of opening Long
IF c6 THEN
BUY 1 CONTRACT AT MARKET
sl=18
ENDIF
// Targets
SET TARGET PPROFIT 180
// new stop over +40
if close-positionprice>=40 then
sl=close-positionprice
endif
set stop ploss sl
Besten Dank. Bringt aber am 3.4.2017 als Resultat -41,9 statt ca. 0
Woran liegts??
Alexander,
Hast du dir mal mit graph die Variablen angeguckt?