Hallo,
weiß jemand wie man eine Position am nächsten Tag zu einer bestimmten Zeit schließt?
Hier ist ein Beispiel. Das Kreuzen der gleitenden Durchschnitte ist das Ausstiegssignal, aber dieses erfolgt erst am nächsten Tag um 11:00 Uhr.
timetoExit=110000
avg1=average[200](close)
avg2=average[50](close)
if not onmarket and avg2 crosses over avg1 then
buy 1 contract at market
endif
if onmarket then
if avg2 crosses under avg1 then
checkTimeToExit=1
signalday=1
endif
if intradaybarindex=0 and checkTimeToExit=1 and signalday=1 then
signalday=0
endif
if checkTimeToExit and signalday=0 and opentime>=timeToExit and opentime[1]<timeToExit then
sell at market
endif
else
checkTimeToExit=0
endif
graphonprice avg1 coloured("blue")
graphonprice avg2 coloured("red")
graph signalday coloured("blue")
Danke.Das Programm funktioniert.
Leider bekomme ich es mit meinen Einstiegsbedingungen nich hin.
Wie müsste es mit meinen Einstiegsbedingungen aussehen?
IF time = 192800 and c0>o0 and c1>o1 and NOT LongOnMarket THEN
buy 5 CONTRACTS AT MARKET
endif
und jetzt am nächsten Tag um 192800 schließen?
Ich weiß nicht, was c0, c1, o0 und o1 sind. Sie müssen in dem Code, den ich Ihnen sende, nur die genannten Variablen ersetzen.
timeToEnter = 192800
timeToExit = 192800
// Benutzerdefinierte Variablen
c0 = close
o0 = open
c1 = close[1]
o1 = open[1]
if not onmarket and opentime>= timeToEnter and opentime[1]<timeToEnter AND c0 > o0 AND c1 > o1 then
buy 5 contract at market
endif
if onmarket then
if checkTimeToExit=0 then
checkTimeToExit=1
signalday=1
endif
if intradaybarindex=0 and checkTimeToExit=1 and signalday=1 then
signalday=0
endif
if checkTimeToExit and signalday=0 and opentime>=timeToExit and opentime[1]<timeToExit then
sell at market
endif
else
checkTimeToExit=0
endif
graph signalday coloured("blue")