Strategia a 1 ora

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #47134 quote
    R05R05
    Participant
    Veteran

    Salve a tutti, vi posto di seguito il codice di una strategia che gira ad 1 ora (che poi altro non è che il turtle soup) ma non fa proprio quello che vorrei. Il sistema deve entrare quando si verifica un massimo o minimo a 20 – 30 periodi e il close è superiore al max o min più alto precedente e seguire il trade col trailing stop, e posizionare il primo stop sotto il massimo (se short) o sotto il minimo (se long) della candela precedente.

    L’entrata è corretta: mi entra alla barra successiva correttamente.

    Funziona anche il trailing stop.

    Ciò che non funziona è

    1. stop sul massimo o minimo della candela di entrata non me lo prende.
    2. nell’immagine allegata mi fa entrare in posizione ma nonostante vada bene me la chiude in negativo.

    Mi aiutate a trovare il problema?

     

    DEFPARAM CumulateOrders = False
    defparam flatbefore = 080000
    defparam flatafter = 180000
    n = 1
    
    // Condizioni per aprire una posizione long
    t = low[1]
    v = low[2]
    y = low[3]
    c1 = close < lowest[30](low)[1]
    
    c11 = close < lowest[20](low)[1]
    
    IF c1 and t>lowest[29](low)[1] and v>lowest[28](low)[1] and y>lowest[27](low)[1] then
    BUY n CONTRACT AT lowest[30](low)[1] + 1*pipsize stop
    ENDIF
    if c11 and t>lowest[19](low)[1] and v>lowest[18](low)[1] and y>lowest[17](low)[1] THEN
    BUY n CONTRACT AT lowest[20](low)[1] + 1*pipsize stop
    ENDIF
    
    // Condizioni per uscire da una posizione long
    c2 = low < lowest[5](low)[1]
     
    IF c2 THEN
    sell AT MARKET
    ENDIF
    
    // Condizioni per aprire una posizione short
    
    t1 = high[1]
    v1 = high[2]
    y1 = high[3]
    
    c1 = close > highest[30](high)[1]
    
    c12 = close > highest[20](high)[1]
     
    IF c1 and t1<highest[29](high)[1] and v1<highest[28](high)[1] and y1<highest[27](high)[1] THEN
    SELLSHORT n CONTRACT AT highest[30](high)[1] - 1*pipsize stop
    ENDIF
    IF c12 and t1<highest[19](high)[1] and v1<highest[18](high)[1] and y1<highest[17](high)[1] THEN
    SELLSHORT n CONTRACT AT highest[20](high)[1] - 1*pipsize stop
    ENDIF
    
    
    // Condizioni per uscire da una posizione di vendita
    c3 = high < highest[5](high)[1]
     
    IF c3 THEN
    exitshort AT MARKET
    ENDIF
    
    // Stop e target
    
    IF close > open THEN               //LONG
    MinLow   = low
    StopLoss = low - 2*pipsize  //2 pips sotto il minimo
    ELSE                               //SHORT
    MaxHigh  = high
    StopLoss = high + 2*pipsize //2 pips sopra il massimo
    ENDIF
    
    
    SET STOP PLOSS StopLoss
    
    
    IF LongOnMarket THEN         //per i LONG
    IF low > MinLow THEN      //verificare che sia un MINIMO più alto
    MinLow = Low           //aggiornare la variabile
    ENDIF
    SELL AT MinLow - 2*pipsize STOP       //aggiornare l'ordine di STOP ad ogni candela
    ENDIF
    IF ShortOnMarket THEN        //per gli SHORT
    IF high < MaxHigh THEN    //verificare che sia un MASSIMO più basso
    MaxHigh = high         //aggiornare la variabile
    ENDIF
    EXITSHORT AT MaxHigh + 2*pipsize STOP //aggiornare l'ordine di STOP ad ogni candela
    ENDIF
    
    doc1-1.pdf
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Strategia a 1 ora


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
R05 @r05 Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 09/24/2017
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...