Hi,
if a daily high is higher than the high of the last week it is a buy. The position should be closed after 6 days, but this don’t happen, i dont know why?
Timeframe (1 WeeK )
MyMHigh = High[1]
MyMLow = Low[1]
TIMEFRAME(1 Day)
Long = High CROSSES OVER myMHigh
Short = Low CROSSES UNDER MyMLow
//Prüfe, ob wir uns in einer neuen Woche befinden und setzen kannKaufen zurück falls ja
If DayOfWeek = 1 Then // Angenommen Montag ist der erste Handelstag
kannKaufen1 = 1 // Erlaube einen neuen Kauf für diese Woche
EndIf
//Prüfen ob in der zweiten Woche gekauft werden kann
If DayOfWeek = 1 AND kannKaufen1 =0 THEN // Angenommen Montag ist der erste Handelstag
kannKaufen2 = 1 // Erlaube einen neuen Kauf für die zweite Woche
EndIf
// Kauflogik
If kannKaufen1=1 And long Then
Buy 1 contract at market
LetzteKaufDatum = BarIndex // Speichere das Datum des Kaufs
kannKaufen1=0 // Verhindere weitere Käufe in dieser Woche
ENDIF
If kannKaufen2=1 And long Then
Buy 1 contract at market
LetzteKaufDatum2 = BarIndex // Speichere das Datum des Kaufs
kannKaufen2=0 // Verhindere weitere Käufe in dieser Woche
ENDIF
// Verkaufslogik - Verkaufe Kontrakt nach 22 Tagen
If BarIndex - LetzteKaufDatum = 6 Then
Sell 1 contract at market
//LetzteKaufDatum = 0 // Setze LetzteKaufDatum zurück nach dem Verkauf
EndIf
If BarIndex - LetzteKaufDatum2 = 6 Then
Sell 1 contract at market
//LetzteKaufDatum2 = 0 // Setze LetzteKaufDatum zurück nach dem Verkauf
EndIf
Add these lines after line 17:
If OnMarket THEN
kannKaufen1 = 0
kannKaufen2 = 0
endif
Thanks, but this didnt solve the problem. With this lines ther will be only one contract in the market, but the buy condition “higher than the high the week before” is every week possible. The problem seems to be that there is no sell if the buy condition is reached.
For example:
1th Day buy condition –> buy a contract at market
7 th Day buy condition for the second week –> buy a contract at market
7th Day sell condition for the first contract “sell after 6 days” reached, but there isnt a sell, the sell is not executed
PRT has so many limitations, I think maybe it’s better not to do such things in PRT.
Why do you enter LONG twice?
Because the entry condition can be reached every week.
You are NOT checking “higher than the high the week before”. You are checking CROSSOVERs, instead, why?