Wie kann ich c1, c2, c3 etc. einen Wert zuweisen?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #98281 quote
    ERoNiX69
    Participant
    Average

    Nehmen wir diese Programmierung als Beispiele:

    indicator1 = Average[200](close)
    indicator2 = Average[100](close)
    indicator3 = Average[50](close)
    indicator4 = Average[20](close)

     

    c1 = (close > indicator1)
    c2 = (close > indicator2)
    c3 = (close > indicator3)
    c4 = (close > indicator4)

     

    Wie gebe ich c1, c2, c3 und c4 einen Wert?

    Z.B.

    c1 = 10
    c2=20
    c3=30
    c4=40

    Da nach sollen die Werte zusammen gerechnet werden, sofern c erfüllt wird; dies ergibbt y

     

    Anschließend soll ein trade eröffnet werden, wenn der gesamt werd von y z.b. 49 übersteigt

    #98318 quote
    Nicolas
    Keymaster
    Master

    Wenn ich die Logik verstehe, möchten Sie eine Punktzahl für alle Bedingungen zusammen berechnen, hier ist ein Versuch unten: (nicht getestet)

    indicator1 = Average[200](close)
    indicator2 = Average[100](close)
    indicator3 = Average[50](close)
    indicator4 = Average[20](close)
    
    c1 = (close > indicator1)
    c2 = (close > indicator2)
    c3 = (close > indicator3)
    c4 = (close > indicator4)
    
    score=0
    if c1 then 
     score=score+10
    endif
    if c2 then 
     score=score+20
    endif
    if c3 then 
     score=score+30
    endif
    if c4 then 
     score=score+40
    endif
    
    if score>= 49 then 
     // BUY or SELLSHORT??
    endif
    ERoNiX69 thanked this post
    #98376 quote
    ERoNiX69
    Participant
    Average

    Scheint zu funktionieren
    Ich bin dir echt dankbar..dachte mir schon dass es so einfach zu schreiben ist, aber egal was ich versucht hab…Computer sagt nein 😀

    Weist du zufällig auch wie ich in dem Moment wo eine Position eröffnet wird einen SL und TP berechnen lasse?

    Nehmen wir wieder die 4 C´s von oben;

    Wenn eine Long Position gekauft wird, sollen die Indikatoren die über dem Kurs liegen als TP und die darunter als SL genutzt werden

    Z.B. (Reihenfolge von oben absteigend)  EMA20, Kurs, 50, 100, 200

    Der wert dem Chart von EMA 20 wird also als TP genutzt

    Und EMA50, 100, 200 werden zsm gerechnet und der wert durch 3 geteilt

    Ich bin dir schon jetzt sehr dankbar haha 😀

    #98389 quote
    ERoNiX69
    Participant
    Average

    // Bedingungen zum Ausstieg von Long-Positionen
    indicator9 = Average[200](close)
    indicator10 = Average[100](close)
    indicator11 = Average[50](close)
    indicator12 = Average[20](close)
    c35 = (close > indicator9)
    c36= (close > indicator10)
    c37= (close > indicator11)
    c38 = (close > indicator12)
    c39 = (close < indicator9)
    c40 = (close < indicator10)
    c41 = (close < indicator11)
    c42 = (close < indicator12)

    score2=0
    IF c35 THEN
    score2=score2 + indicator9
    ENDIF
    IF c36 THEN
    score2=score2 + indicator10
    ENDIF
    IF c37 THEN
    score2=score2 + indicator11
    ENDIF
    IF c38 THEN
    score2=score2 + indicator12
    ENDIF

    score3=0
    IF c39 THEN
    score3=score3 + indicator9
    ENDIF
    IF c40 THEN
    score3=score3 + indicator10
    ENDIF
    IF c41 THEN
    score3=score3 + indicator11
    ENDIF
    IF c42 THEN
    score3=score3 + indicator12
    ENDIF

    If LongOnMarket THEN
    SET STOP pLOSS score3 pTRAILING 200
    SET TARGET pPROFIT score2
    ENDIF

     

    ich hab das jz so
    aber iwi glaube ich passt das noch nicht ganz

    und da ich erlaubt habe mehrere Positionen zu kaufen, bin ich mir auch nicht sicher ob das für jede neu berechnet wird (bis der Wert halt von einer oder allen bis dahin geöffneten Positionen erreicht wird)

     

    und ich müsste auch noch wissen wie ich nicht nur mit vollen zahlen rechnen kann..also z.b. 6,5 oder 2,75 etc.

    #98405 quote
    ERoNiX69
    Participant
    Average

    score3=0
    score7=0
    score11=score3/score7
    IF c39 THEN
    score3=score3 + indicator9
    score7=score7 + 1
    ENDIF
    IF c40 THEN
    score3=score3 + indicator10
    score7=score7 + 1
    ENDIF
    IF c41 THEN
    score3=score3 + indicator11
    score7=score7 + 1
    ENDIF
    IF c42 THEN
    score3=score3 + indicator12
    score7=score7 + 1
    ENDIF

    If LongOnMarket THEN
    SET STOP LOSS score11 ptrailing 50
    SET TARGET PROFIT score10
    ENDIF

     

    So ist das falschen code kopiert*

    #98420 quote
    Nicolas
    Keymaster
    Master
    • Um Code zu schreiben , benutzen Sie bitte die Schaltfläche <> "PRT Code einfügen".

    Entschuldigung, aber ich bin in der Übersetzung verloren. Ich verstehe nicht, was Sie mit dem Code machen möchten. Könnten Sie bitte einfache Worte verwenden, um jeden Schritt zu erklären? Danke im Voraus.

    #98435 quote
    ERoNiX69
    Participant
    Average

    Ok ich füge bei bedarf einen code ein wenn ich zuhause bin.

     

    Ich möchte erstmal wissen wie ich mit Kommazahlen rechnen 😀

    (Z.b. 0,1  6,5   2,75 etc)

     

     

    Und dein code scheint zu funktionieren 😉

    Also haben wir jetzt einen Trade eröffnet (sagen wir Long; Buy)

    Dieser Trade braucht aber noch einen Stop Loss / Take Profit

    Der soll berechnet werden aus dem Gleitenden Durchschnitt

    Befindet sich der Indikator über dem Kurs wird er zu Take Profit

    Darunter zu Stop Loss

    Befinden sich mehrer darunter (bzw. Darüber) werden diese zusammen gerechnet und durch die anzahl wieder geteilt

     

     

    Dies soll sowohl für long als auch short positionen möglich sein

    #98738 quote
    Nicolas
    Keymaster
    Master

    Wenn Sie den Wert eines Indikators wie MA verwenden möchten, um den Stop-Loss und den Take-Profit zu berechnen, können Sie dies beispielsweise für einen langen Auftrag wie folgt tun:

    ma20 = average[20]
    
    if buycondition then 
     buy at market 
     set stop loss close-ma20
     set target profit (close-ma20)*2
    endif
    #99200 quote
    ERoNiX69
    Participant
    Average

    Ich danke dir erstmal für deine Hilfe

    Ich guck mich mal weiter im Forum um

    Ich hätte nur noch 2 Fragen

    -Wieso wird ein Befehl mit Leerzeichen geschrieben und ein anderer ohne? Hat das einen Einfluss aufs System?

    -Wie kann ich x,xxxx als Zahl eingeben?

    #99959 quote
    ERoNiX69
    Participant
    Average
    // Festlegen der Code-Parameter
    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    indicator1 = Momentum[12](close)
    c1 = (indicator1 > indicator1[1])
    c2 = (indicator1 < indicator1[1])
    
    // STOPS AND TARGETS
    indicator9 = Average[200](close)
    indicator10 = Average[100](close)
    indicator11 = Average[50](close)
    indicator12 = Average[20](close)
    
    SLTP1 = (close > indicator9)
    SLTP2 = (close > indicator10)
    SLTP3 = (close > indicator11)
    SLTP4 = (close > indicator12)
    
    SLTP5 = (close < indicator9)
    SLTP6 = (close < indicator10)
    SLTP7 = (close < indicator11)
    SLTP8 = (close < indicator12)
    
    LSL1 = 0
    xLSL = 0
    pLSL = LSL1 / xLSL
    
    IF SLTP1 THEN
    LSL1 = LSL1 + indicator9
    xLSL = xLSL + 1
    ENDIF
    IF SLTP2 THEN
    LSL1 = LSL1 + indicator10
    xLSL = xLSL + 1
    ENDIF
    IF SLTP3 THEN
    LSL1 = LSL1 + indicator11
    xLSL = xLSL + 1
    ENDIF
    IF SLTP4 THEN
    LSL1 = LSL1 + indicator12
    xLSL = xLSL + 1
    ENDIF
    
    
    LTP1 = 0
    xLTP = 0
    pLTP = LTP1 / xLTP
    
    IF SLTP5 THEN
    LTP1 = LTP1 + indicator9
    xLTP = xLTP + 1
    ENDIF
    IF SLTP6 THEN
    LTP1 = LTP1 + indicator10
    xLTP = xLTP + 1
    ENDIF
    IF SLTP7 THEN
    LTP1 = LTP1 + indicator11
    xLTP = xLTP + 1
    ENDIF
    IF SLTP8 THEN
    LTP1 = LTP1 + indicator12
    xLTP = xLTP + 1
    ENDIF
    
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP LOSS pLSL
    SET TARGET PROFIT pLTP
    ELSE
    IF c2 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    SET STOP LOSS pLTP
    SET TARGET PROFIT pLSL
    ENDIF
    ENDIF
    

    Das ist mal eine gekürzte Version vom Code…

    Es wird einfach kein stop loss oder take profit gesetzt…

    Ich habe exakt das selbe Ergebnis ohne SL/TP

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

Wie kann ich c1, c2, c3 etc. einen Wert zuweisen?


ProOrder: Automatischer Handel & Backtesting

New Reply
Author
author-avatar
ERoNiX69 @eronix69 Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by ERoNiX69
6 years, 8 months ago.

Topic Details
Forum: ProOrder: Automatischer Handel & Backtesting
Language: German
Started: 05/12/2019
Status: Active
Attachments: No files
Logo Logo
Loading...