Buy a long every week if the high is higher than the last high

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #228381 quote
    killerplatuze
    Participant
    New

    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
    
    Orders.jpg Orders.jpg
    #228406 quote
    robertogozzi
    Moderator
    Master

    Add these lines after line 17:

    If OnMarket THEN
       kannKaufen1 = 0
       kannKaufen2 = 0
    endif
    killerplatuze thanked this post
    #228424 quote
    killerplatuze
    Participant
    New

    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

    #228472 quote
    killerplatuze
    Participant
    New

    PRT has so many limitations, I think maybe it’s better not to do such things in PRT.

    #228477 quote
    robertogozzi
    Moderator
    Master

    Why do you enter LONG twice?

    #228504 quote
    killerplatuze
    Participant
    New

    Because the entry condition can be reached every week.

    #228527 quote
    robertogozzi
    Moderator
    Master

    You are NOT checking “higher than the high the week before”. You are checking CROSSOVERs, instead, why?

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Buy a long every week if the high is higher than the last high


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by robertogozzi
1 year, 12 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/19/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...