Short-Position läuft durch – Befehle werden nicht richtig abgearbeitet

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #90278 quote
    JohnnyBlaze
    Participant
    New

    Guten Tag liebe PRT-Programmierer,

    dies ist mein erster Post und ich stehe vor folgendem Rätsel: Die Strategie, die ich mir überlegt habe, soll sowohl auf der Long- als auch “spiegelverkehrt” auf der Short-Seite funktionieren.

    Long wird auch genauso durchgeführt, wie beabsichtigt. Wenn ich jedoch die Vorzeichen umdrehe für die Short-Trades, werden Positionen nicht so wie beabsichtigt geschlossen, sondern viele Positionen bleiben einfach unzählige Bars lang offen, obwohl die Bedingungen zum Schließen längst eingetreten sind und die Postition geschlossen werden müsste.

    Weiß jemand Rat?

    Hier der Code für Long – Variablen: n=1;5 [1]  ma=5;300 [5] (funktioniert tadellos):

    DEFPARAM CumulateOrders = true
    
    trend = close > Average[ma](close)
    
    IF countofposition = 0 and trend THEN
    BUY 1 share AT HIGH STOP
    SET STOP %LOSS n
    tp1= tradeprice
    ENDIF
    
    IF countofposition = 1 and trend THEN
    BUY 1 share AT HIGH STOP
    SET STOP %LOSS n
    tp2= tradeprice
    ENDIF
    
    IF LONGONMARKET and countofposition = 1 and close > tp1 THEN
    SELL 1 share AT Market
    ENDIF
    
    IF LONGONMARKET and countofposition = 2 and close > tp2 THEN
    SELL 1 share AT Market
    ENDIF
    

     

    Und hier der Code für Short – Variablen: n=1;5 [1]  ma=5;300 [5] (Positionen werden nicht geschlossen, zweite Position wird gar nicht erst eröffnet)

    DEFPARAM CumulateOrders = true
    
    trend = close < Average[ma](close)
    
    IF countofposition = 0 and trend THEN
    SELLSHORT 1 SHARE AT LOW STOP
    SET STOP %LOSS n
    tp1 = tradeprice
    ENDIF
    
    IF countofposition = 1 and trend THEN
    SELLSHORT 1 SHARE AT LOW STOP
    SET STOP %LOSS n
    tp2 = tradeprice
    ENDIF
    
    IF SHORTONMARKET and countofposition = 1 and close < tp1 THEN
    EXITSHORT 1 SHARE AT MARKET
    ENDIF
    
    IF SHORTONMARKET and countofposition = 2 and close < tp2 THEN
    EXITSHORT 1 SHARE AT MARKET
    ENDIF
    
    #90387 quote
    Nicolas
    Keymaster
    Master

    COUNTOFPOSITION ist bei kurzen Aufträgen negativ. Ihre Bedingung sollte also geändert werden, um sie entsprechend zu testen.

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

Short-Position läuft durch – Befehle werden nicht richtig abgearbeitet


ProOrder: Automatischer Handel & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
7 years ago.

Topic Details
Forum: ProOrder: Automatischer Handel & Backtesting
Language: German
Started: 02/01/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...