Einstieg 5 Tage vor End e des monats

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #188425 quote
    axmichi
    Participant
    Senior

    Hallo,

    Hallo ich möchte gern ca. 5 Tage vor Monatsende einsteigen und wieder am 5 tag des nächsten Monats aussteigen.

     

    Was ist an diesen Code falsch?

    EntryDay = 20
    
    ExitDay = 5
    
    if not onmarket and Day = Entryday then
    buy 1 shares at Market
    
    if longonmarket and Day = ExitDay then
    sell at market
    #188426 quote
    axmichi
    Participant
    Senior

    die einstiege sind nicht jeden Monat und obwohl der trade im nächsten Monat geschlossen werden soll läuft er manchmal 3 Monate?!

    #188429 quote
    robertogozzi
    Moderator
    Master

    Die Tage 5 und 20 sind nicht immer Handelstage, in diesem Fall werden die Anweisungen in diesem Monat ignoriert, bis zum nächsten, etc …

    Außerdem fehlen die abschließenden ENDIFs der IF-Blöcke.

    Dieser Code tritt an den von Ihnen angegebenen Tagen ein und aus, oder an den unmittelbar folgenden, wenn es sich nicht um Handelstage handelt:

    EntryDay = 20
    
    ExitDay  = 5
    
    if not onmarket and ((Day = Entryday) OR ((Day > Entryday) AND (Day[1] < Entryday))) then
       buy 1 shares at Market
    endif
     
    if longonmarket and ((Day = ExitDay) OR ((Day > ExitDay) AND (Day[1] < ExitDay))) then
       sell at market
    endif
    #188472 quote
    axmichi
    Participant
    Senior

    Danke schön.

    Wenn möglich hätte ich gern noch eine Erweiterung.

    Ich würde gern dass das System nur eine Trades macht, wenn der Index S&P über seinem gleitenden Durchschnitt von 50 liegt.

     

    Ich bin mir nicht sicher ob das überhaupt geht!?

     

    Danke sehr

    #188488 quote
    robertogozzi
    Moderator
    Master

    Hier ist es (ich habe es nicht ausprobiert):

    EntryDay = 20
    ExitDay  = 5
    MA       = close > average[50,0](close)
    if not onmarket and ((Day = Entryday) OR ((Day > Entryday) AND (Day[1] < Entryday))) AND MA then
       buy 1 shares at Market
    endif
    if longonmarket and ((Day = ExitDay) OR ((Day > ExitDay) AND (Day[1] < ExitDay))) then
       sell at market
    endif
    #188498 quote
    axmichi
    Participant
    Senior

    Hallo oh sorry da habe ich mich wohl nicht richtig beschrieben.

    Das System soll immer am 20 . Tag ein steigen aber z.b in eine Aktie amazon !! und der Index s&p soll über dem gd 50 sein. Sorry für das missverständnis
    #188505 quote
    robertogozzi
    Moderator
    Master
    Es ist nicht möglich, mit mehr als einem Finanzinstrument zu operieren. Wenn Sie bei Amazon arbeiten, können Sie nicht auf SP oder irgendetwas anderes zugreifen. Wenn Sie auf SP operieren, können Sie nicht auch auf Amazon usw. operieren, da auf deren Informationen und Daten nicht gleichzeitig zugegriffen werden kann.
    #188728 quote
    axmichi
    Participant
    Senior
    Hallo ok das geht nicht. Ist es denn möglich diesen Ansatz nur in bestimmten Zeiten (Datum)  zu handeln? Nur ein Beispiel Z:b vom 20.02.  –  10.03. und  10.10.  – 06.11.  in jedem Jahr Ich möchte damit die jahre zurück testen ob bestimmte Zeiträume sich lohnen.   Danke….
    #188796 quote
    axmichi
    Participant
    Senior
    wie ist der Code für den Einstieg an jedem 20.02. in jedem Jahr und dem Ausstieg an jedem 10.03. in jedem jahr Das auch mit zwei weiteren Datum Einstieg 10.10 und Ausstieg 06.11. Könnte der code lauten c1 = month[2] and Date[20] or month[10] and Date[10] // für die Einstiege c2 = month[3] and Date[10] or month[11] and date[6] // für die Ausstiege if not longonmarket and c1 then buy 1 shares at market if longonmarket and c1 then sell at market Bei mir funktioniert es leider nicht ??   Danke
    #188837 quote
    robertogozzi
    Moderator
    Master
    Dort:
    StartDate1 = 20200510           //from May 5th,  2020
    EndDate1   = 20200831           //to   Aug 31th, 2020
    //
    StartDate2 = 20211101           //from Nov 1st,  2021
    EndDate2   = 20220118           //to   Jan 18th, 2022
    //
    DateOK     = (Date >= StartDate1 AND Date <= EndDate1) OR (Date >= StartDate2 AND Date <= EndDate2)
    //
    MA         = close > average[50,0](close)
    if not onmarket and DateOK AND MA then
       buy 1 shares at Market
    endif
    set stop   pLoss   400
    set target pProfit 1000
    #189093 quote
    axmichi
    Participant
    Senior
    Danke Dir für die Hilfe
    #189129 quote
    axmichi
    Participant
    Senior
    Sorry, aber ich habe es so gemeint, dass die Trades in jedem Jahr ausgeführt werden sollen. Praktisch die selben Dates aber in jedem Jahr!
    #189200 quote
    robertogozzi
    Moderator
    Master
    Da ist er:
    StartMonth1 = 5              //from May 10th
    StartDay1   = 10
    EndMonth1   = 8              //to   Aug 31th
    EndDay1     = 31
    //
    StartMonth2 = 11             //from Nov 1st
    StartDay2   = 1
    EndMonth2   = 1              //to   Jan 18th
    EndDay2     = 18
    //
    DateOK1     = 0
    DateOK2     = 0
    //
    // First date
    //
    IF EndMonth1 < StartMonth1 THEN
       IF OpenMonth < EndMonth1 THEN
          DateOK1 = 1
       ELSIF OpenMonth = EndMonth1 THEN
          IF OpenDay <= EndDay1 THEN
             DateOK1 = 1
          ENDIF
       ENDIF
    ELSIF EndMonth1 = StartMonth1 THEN
       IF OpenMonth = EndMonth1 THEN
          IF (OpenDay >= StartDay1) OR (OpenDay <= EndDay1) THEN
             DateOK1 = 1
          ENDIF
       ENDIF
    ELSE
       IF (OpenMonth = StartMonth1) THEN
          IF (OpenDay >= StartDay1) THEN
             DateOK1 = 1
          ENDIF
       ELSIF (OpenMonth = EndMonth1) THEN
          IF (OpenDay <= EndDay1) THEN
             DateOK1 = 1
          ENDIF
       ELSIF (OpenMonth > StartMonth1) AND (OpenMonth < EndMonth1) THEN
          DateOK1 = 1
       ENDIF
    ENDIF
    //
    // Second Date
    //
    IF EndMonth2 < StartMonth2 THEN
       IF OpenMonth < EndMonth2 THEN
          DateOK2 = 1
       ELSIF OpenMonth = EndMonth2 THEN
          IF OpenDay <= EndDay2 THEN
             DateOK2 = 1
          ENDIF
       ENDIF
    ELSIF EndMonth2 = StartMonth2 THEN
       IF OpenMonth = EndMonth2 THEN
          IF (OpenDay >= StartDay2) OR (OpenDay <= EndDay2) THEN
             DateOK2 = 1
          ENDIF
       ENDIF
    ELSE
       IF (OpenMonth = StartMonth2) THEN
          IF (OpenDay >= StartDay2) THEN
             DateOK2 = 1
          ENDIF
       ELSIF (OpenMonth = EndMonth2) THEN
          IF (OpenDay <= EndDay2) THEN
             DateOK2 = 1
          ENDIF
       ELSIF (OpenMonth > StartMonth2) AND (OpenMonth < EndMonth2) THEN
          DateOK2 = 1
       ENDIF
    ENDIF
    //
    DateOK     = DateOK1 OR DateOK2
    //
    MA         = close > average[20,0](close)
    if not onmarket and DateOK AND MA then
       buy 1 shares at Market
    endif
    set stop   pLoss   200
    set target pProfit 400
    #189360 quote
    axmichi
    Participant
    Senior
    ganz toll, danke und es funktioniert auch auf kleineren Timeframes Danke
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.

Einstieg 5 Tage vor End e des monats


ProOrder: Automatischer Handel & Backtesting

New Reply
Author
author-avatar
axmichi @axmichi Participant
Summary

This topic contains 13 replies,
has 2 voices, and was last updated by axmichi
3 years, 11 months ago.

Topic Details
Forum: ProOrder: Automatischer Handel & Backtesting
Language: German
Started: 02/17/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...