Offset negativo – codice 10 secondi

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

    Buongiorno

    Ho realizzato un codice , a 10 secondi , che su probacktest funziona ma ogni volta che lo faccio girare sulla piattaforma reale si blocca e compare poi la dicitura :

    “Il sistema di trading si è interrotto perché il programma ha usato un offset negativo o uguale a zero ( ex: close=[-10] durante la valutazione dell’ ultima candela . La prego di aggiungere protezioni al suo codice per prevenire offsets negativio uguali a zero”

    Cosa devo fare ? Cosa si intende per protezioni ?

    Grazie

    Raffaele

    #46745 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Senza il codice è impossibile dare una risposta. Se ti va devi postarlo indicando anche su quale strumento lo utilizzi.

    #46756 quote
    NicolasNicolas
    Keymaster
    Legend

    Il tuo post appartiene al forum di supporto ProOrder, lo ho spostato di conseguenza.
    Una soluzione facile sarebbe quella di impostare un minimo minimo come questo:
    (diciamo che stai usando una media mobile)

    indicator = average[max(1,calculatedperiod)]

    In questo modo il tuo ‘calculatedperiod’ non verrà utilizzato se è inferiore a 1.

    #46859 quote
    RAFFAELERAFFAELE
    Participant
    New

    Vi ringrazio per i consigli ma non ho capito
    Allego il codice nella speranza che possiate correggerlo .
    Il periodo è 10 secondi il mercato è DAX .
    Il problema è che il codice funziona nella simulazione , quando invece lo inserisco in esecuzione si blocca con la dicitura :

    il sistema di trading si è interrotto perché il programma ha usato un offset negativo o uguale a zero ( ex: close=[-10]) durante la valutazione dell’ ultima candela . La prego di aggiungere protezioni al suo codice per prevenire offsets negativio uguali a zero

    DEFPARAM FlatAfter = 173000
    defparam cumulateorders= false
    defparam preloadbars = 30000
    OraInizio = 090000
    oralimite =173000
    tagliaposizione=1
    OraInizio1 = 090000
    d=1.1

    s=4
    q=2.3
    s1=7.5
    q1=6
    t=3

    mysupport=40
    mytarget=150

    if time=orainizio then
    p= close
    endif

    if close>p+d then
    k=1
    elsif closep+s1 then
    v=2
    elsif longonmarket and highest[barindex-tradeindex](close)

    p+s then
    v=1
    else
    v=10
    endif

    if shortonmarket and lowest[barindex-tradeindex](close)<p-s1 then
    v1=2
    elsif shortonmarket and lowest[barindex-tradeindex](close)p-s1 then
    v1=1
    else
    v1=-10
    endif

    if time>orainizio1 and time=t then
    sell at p+q stop

    endif

    if time>orainizio1 and time=t then
    exitshort at p-q stop

    endif
    set target profit mytarget
    set stop trailing mysupport

    #46861 quote
    RAFFAELERAFFAELE
    Participant
    New

    Pardon il codice da correggere è questo .

    DEFPARAM FlatAfter = 173000
    defparam cumulateorders= false
    defparam preloadbars = 30000
    OraInizio = 090000
    oralimite =173000
    Tagliaposizione=1
    OraInizio1 = 090000
    d=1.1

    s=4
    q=2.3
    s1=7.5
    q1=6
    s2=16
    q2=8

    mysupport=40
    mytarget=150
    if time=orainizio then
    p= close

    endif
    if close>p+d then
    k=1
    elsif closep+s2 then
    v=3
    elsif longonmarket and highest[barindex-tradeindex](close)>p+s1 and highest[barindex-tradeindex](close)<p+s2 then
    v=2
    elsif longonmarket and highest[barindex-tradeindex](close)

    p+s then
    v=1
    elsif longonmarket and highest[barindex-tradeindex](close)<p+s then
    v=0
    else
    v=10
    endif

    if shortonmarket and lowest[barindex-tradeindex](close)<p-s2 then
    v1=3
    elsif shortonmarket and lowest[barindex-tradeindex](close)p-s2 then
    v1=2
    elsif shortonmarket and lowest[barindex-tradeindex](close)p-s1 then
    v1=1
    elsif shortonmarket and lowest[barindex-tradeindex](close)>p-s then
    v1=0
    else
    v1=-10
    endif

    if time>orainizio1 and timeorainizio1 and time<oralimite and k=1 and not onmarket then
    sellshort tagliaposizione contract at p stop

    elsif v1=3 then
    exitshort at p-q2 stop

    elsif v1=2 then
    exitshort at p-q1 stop

    elsif v1=1 then
    exitshort at p-q stop

    endif
    set target profit mytarget
    set stop trailing mysupport

    #46877 quote
    NicolasNicolas
    Keymaster
    Legend

    >> Per chiarezza dei messaggi sul Forum di Prorealcode, separate le parti del vostro codice usando il pulsante per l’inserimento del testo del codice. <<

    #47253 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    In alcune righe, dove c’è IF manca la relazione che che deve esserci tra vari valori ed inoltre le condizioni sono pste su righe diverse.

    T’invito a ripostare il codice completo utilizzando il tasto “insert PRT code” per renderlo leggibile.

Viewing 7 posts - 1 through 7 (of 7 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

Offset negativo – codice 10 secondi


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
RAFFAELE @raffaele Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
9 years ago.

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