Qualcuno mi può dire dove sto sbagliando nel codice ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #47276 quote
    iceman89
    Participant
    Average

    Vorrei sapere se qualcuno mi può dire dove sto sbagliando nel mio trading system allego i codici sia candele heiken ashi sia candele giapponesi.

    1. ts candele heiken ashi
      DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
      // Il sistema cancellerà tutti gli ordini in attesa e chiuderà tutte le posizioni a 0:00. Dopo l'orario "Flat Before" non saranno piazzati nuovi ordini o posizioni; in base all'orario di negoziazione dello Strumento Finanziario usato.
      DEFPARAM FLATBEFORE = 100000
      // Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all'orario "Flat After"; in base all'orario di negoziazione dello Strumento Finanziario usato.
      DEFPARAM FLATAFTER = 020000
      
      // Impedisce al sistema di creare nuovi ordini per entrare a mercato o aumentare la taglia della posizione prima dell'orario specificato
      noEntryBeforeTime = 095900
      IF noEntryBeforeTime > 020000 THEN
      timeEnterBefore = time >= noEntryBeforeTime OR time < 020000
      ELSE
      timeEnterBefore = time >= noEntryBeforeTime AND time < 020000
      ENDIF
      
      // Impedisce al sistema di piazzare nuovi ordini per entrare a mercato o aumentare la taglia della posizione dopo l'orario indicato
      noEntryAfterTime = 020100
      IF noEntryAfterTime > 020000 THEN
      timeEnterAfter = time > 100000 AND time < noEntryAfterTime
      ELSE
      timeEnterAfter = time > 100000 OR time < noEntryAfterTime
      ENDIF
      
      // Impedisce al sistema di tradare in giorni specifici della settimana
      daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
      
      
      ONCE InizioLong = 100000
      // Inizio orario di negoziazione LONG dalle 10:00:00 in poi
      ONCE FineLong = 230000
      // Fine orario di negoziazione LONG dopo le 23:00:00
      ONCE InizioShort = 100000
      // Inizio orario di negoziazione SHORT dalle 10:00:00 in poi
      ONCE FineShort = 020000
      // Fine orario di negoziazione SHORT dopo le 02:00:00
      
      
      //Condizioni LONG e SHORT
      
      //Parametri candele Heikin Ashi
      DojiSize = 5 //x% percent of body size compared to the complete range of the candlestick
      // ---
      
      IF BARINDEX = 0 THEN
      xClose = TotalPrice
      xOpen = (xOpen[1] + xClose[1]) / 2
      xHigh = Max(xOpen, xClose)
      xLow = Min(xOpen, xClose)
      xHigh = Max(High,xHigh)
      xLow = Min(Low,xLow)
      ENDIF
      
      doji=(abs(xopen - xclose) <= (xhigh - xlow) * DojiSize/100)
      
      //Entrare LONG e SHORT HEIKIN ASHI
      ONCE PreviousStatus = 0
      IF BarIndex = 0 THEN
      XClose = TotalPrice
      XOpen = (Open + Close) / 2
      ELSE
      XClose = TotalPrice
      XOpen = (XOpen[1] + Xclose[1]) / 2
      ENDIF
      IF XClose >= XOpen THEN
      IF NOT LONGONMARKET and NOT doji and NOT daysforbiddenentry and timeenterbefore and timeenterafter and   PreviousStatus <> 1 and time >= InizioLong AND time <= FineLong THEN
      //LONG solo nell'orario stabilito.
      BUY 1 SHARES AT MARKET NEXTBAROPEN
      PreviousStatus = 1
      ENDIF
      ELSE
      IF NOT SHORTONMARKET and NOT doji and NOT  daysforbiddenentry and timeenterbefore and timeenterafter and  PreviousStatus <> -1 and time >= InizioShort AND time<= FineShort THEN
      //SHORT solo nell'orario stabilito.
      SELLSHORT 1 SHARES AT MARKET NEXTBAROPEN
      PreviousStatus = -1
      ENDIF
      ENDIF
      
      //Uscire LONG e SHORT HEIKIN ASHI
      
      IF time = FineLong THEN                                         //Chiudere le posizioni LONG all'ora stabilita.
      IF LONGONMARKET THEN
      SELL AT MARKET
      ENDIF
      ELSE
      IF time = FineShort THEN                                       //Chiudere le posizioni SHORT all'ora stabilita
      IF SHORTONMARKET THEN
      EXITSHORT AT MARKET
      ENDIF
      ENDIF
      ENDIF

      2. ts candele giapponesi

    2. //Definizione dei parametri del codice
      DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
      // Il sistema cancellerà tutti gli ordini in attesa e chiuderà tutte le posizioni a 0:00. Dopo l'orario "Flat Before" non saranno piazzati nuovi ordini o posizioni; in base all'orario di negoziazione dello Strumento Finanziario usato.
      DEFPARAM FLATBEFORE = 100000
      // Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all'orario "Flat After"; in base all'orario di negoziazione dello Strumento Finanziario usato.
      DEFPARAM FLATAFTER = 020000
      
      // Impedisce al sistema di creare nuovi ordini per entrare a mercato o aumentare la taglia della posizione prima dell'orario specificato
      noEntryBeforeTime = 095900
      IF noEntryBeforeTime > 020000 THEN
      timeEnterBefore = time >= noEntryBeforeTime OR time < 020000
      ELSE
      timeEnterBefore = time >= noEntryBeforeTime AND time < 020000
      ENDIF
      
      // Impedisce al sistema di piazzare nuovi ordini per entrare a mercato o aumentare la taglia della posizione dopo l'orario indicato
      noEntryAfterTime = 020100
      IF noEntryAfterTime > 020000 THEN
      timeEnterAfter = time > 100000 AND time < noEntryAfterTime
      ELSE
      timeEnterAfter = time > 100000 OR time < noEntryAfterTime
      ENDIF
      
      // Impedisce al sistema di tradare in giorni specifici della settimana
      daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
      
      ONCE InizioLong = 100000
      // Inizio orario di negoziazione LONG dalle 10:00:00 in poi
      ONCE FineLong = 230000
      // Fine orario di negoziazione LONG dopo le 23:00:00
      ONCE InizioShort = 100000
      // Inizio orario di negoziazione SHORT dalle 10:00:00 in poi
      ONCE FineShort = 020000
      // Fine orario di negoziazione SHORT dopo le 02:00:00
      
      //Condizioni LONG e SHORT
      
      //Parametri candele GIAPPONESI STANDARD
      DojiSize = 0.05
      // ---
      doji=(abs(open - close) <= (high - low) * DojiSize)
      
      //Entrare LONG e SHORT CANDELE GIAPPONESI STANDARD
      ONCE PreviousStatus = 0
      IF NOT LONGONMARKET and NOT doji and NOT daysforbiddenentry and timeenterbefore and timeenterafter and   PreviousStatus <> 1 and time >= InizioLong AND time <= FineLong THEN
      //LONG solo nell'orario stabilito.
      BUY 1 SHARES AT MARKET NEXTBAROPEN
      
      PreviousStatus = 1
      ENDIF
      
      IF NOT SHORTONMARKET and NOT doji and NOT daysforbiddenentry and timeenterbefore and timeenterafter and  PreviousStatus <> -1 and time >= InizioShort AND time<= FineShort THEN
      //SHORT solo nell'orario stabilito.
      SELLSHORT 1 SHARES AT MARKET NEXTBAROPEN
      PreviousStatus = -1
      ENDIF
      
      //Uscire LONG e SHORT CANDELE GIAPPONESI STANDARD
      
      IF time = FineLong THEN                                         //Chiudere le posizioni LONG all'ora stabilita.
      IF LONGONMARKET THEN
      SELL AT MARKET
      ENDIF
      ELSE
      IF time = FineShort THEN                                       //Chiudere le posizioni SHORT all'ora stabilita
      IF SHORTONMARKET THEN
      EXITSHORT AT MARKET
      ENDIF
      ENDIF
      ENDIF

      la domanda è dove sto sbagliando? sia se lo voglio lanciare in probacktest o proorder cioè in REALE?

    Grazie mille in Anticipo a chi mi da una risposta.

    #47278 quote
    robertogozzi
    Moderator
    Master

    Non sono entrato nel merito della strategia, ma già ad un primo sguardo vedo che FLATAFTER e FLATBEFORE contengono orari incompatibili, FLATAFTER non può avere valori inferiori a FLATBEFORE altrimenti nessun trade verrà mai eseguito.

    Anche nel codice mi sembra ci sia questo errore logico, non si può chiedere che qualcosa venga fatto prima delle 10 ed allo stesso tempo che niente debba essere fatto dopo le 2!

    Inoltre è bene sempre specificare il Timeframe e lo strumento su cui la strategia deve operare, altrimenti chi legge non può fare test ed eventualmente aiutarti.

    #47289 quote
    iceman89
    Participant
    Average

    cosi invece potrebbe andare  per esempio mercato azionario americano titolo apple all sessions (10:00:00-02:00:00) orario di negoziazione.

    timeframe 1minuto

    il codice così potrebbe funzionare in probacktest o reale?

    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    // Il sistema cancellerà tutti gli ordini in attesa e chiuderà tutte le posizioni a 0:00. Dopo l'orario "Flat Before" non saranno piazzati nuovi ordini o posizioni; in base all'orario di negoziazione dello Strumento Finanziario usato.
    
    // Impedisce al sistema di tradare in giorni specifici della settimana
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    ONCE InizioLong = 100000
    // Inizio orario di negoziazione LONG dalle 10:00:00 in poi
    ONCE FineLong = 230000
    // Fine orario di negoziazione LONG dopo le 23:00:00
    ONCE InizioShort = 100000
    // Inizio orario di negoziazione SHORT dalle 10:00:00 in poi
    ONCE FineShort = 020000
    // Fine orario di negoziazione SHORT dopo le 02:00:00
    
    //Condizioni LONG e SHORT
    
    //Parametri candele Heikin Ashi
    DojiSize = 5 //x% percent of body size compared to the complete range of the candlestick
    // ---
    
    IF BARINDEX = 0 THEN
    xClose = TotalPrice
    xOpen = (xOpen[1] + xClose[1]) / 2
    xHigh = Max(xOpen, xClose)
    xLow = Min(xOpen, xClose)
    xHigh = Max(High,xHigh)
    xLow = Min(Low,xLow)
    ENDIF
    
    doji=(abs(xopen - xclose) <= (xhigh - xlow) * DojiSize/100)
    
    //Entrare LONG e SHORT HEIKIN ASHI
    ONCE PreviousStatus = 0
    IF BarIndex = 0 THEN
    XClose = TotalPrice
    XOpen = (Open + Close) / 2
    ELSE
    XClose = TotalPrice
    XOpen = (XOpen[1] + Xclose[1]) / 2
    ENDIF
    
    IF XClose >= XOpen THEN
    IF NOT LONGONMARKET and NOT doji and NOT daysforbiddenentry  and PreviousStatus <> 1 and time >= InizioLong AND time <= FineLong THEN
    //LONG solo nell'orario stabilito.
    BUY 1 SHARES AT MARKET NEXTBAROPEN
    PreviousStatus = 1
    ENDIF
    ELSE
    IF NOT SHORTONMARKET and NOT doji and NOT  daysforbiddenentry and PreviousStatus <> -1 and time >= InizioShort AND time<= FineShort THEN
    //SHORT solo nell'orario stabilito.
    SELLSHORT 1 SHARES AT MARKET NEXTBAROPEN
    PreviousStatus = -1
    ENDIF
    ENDIF
    
    //Uscire LONG e SHORT HEIKIN ASHI
    
    IF time = FineLong THEN                                         //Chiudere le posizioni LONG all'ora stabilita.
    IF LONGONMARKET THEN
    SELL AT MARKET
    ENDIF
    ELSE
    IF time = FineShort THEN                                       //Chiudere le posizioni SHORT all'ora stabilita
    IF SHORTONMARKET THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    ENDIF

    stessa cosa per candele giapponesi standard o seno non so ditemi voi?

    #47292 quote
    robertogozzi
    Moderator
    Master

    Io l’ho provato sul DAX ad 1 ora e non da risultati.

    Mi sembra che alle righe 11 e 13 ci sia un’incongruenza, come ho detto prima. C’è una fine che precede l’inizio, mi pare impossibile da verificarsi!!!

    Specifica bene cosa vuoi che faccia la tua strategia e quando vuoi che lo faccia e su quale timeframe.

    #47675 quote
    iceman89
    Participant
    Average

    io vorrei che il mio  ts  funzioni sia con candele heikin ashi e sia con candele normali con time frame da 1 a 10 minuti e se possibile che funzioni anche in vista (x) ticks.

    che apra e che chiuda a mercato ogni posizione; esempio: apri-chiudi long, apri-chiudi short,escludendo le candele doji dal sistema,in modo che quando ne riscontra una non apre posizioni ne long che short al presentarsi una candela doji.

    frammentando il capitale su  più ordini e più strumenti in modo da adattarsi a qualsiasi strumento.

    nei giorni che vanno  da LUNEDì A VENERDì, in orari prestabiliti ,(esempio: alcuni mercati come azioni americane estese con IG MARKETS vanno dalle 10:00:00 alle 02:00:00 fino a giovedì mentre il venerdì fino alle 23:00:00). capisci cosa intendo io.

    in modo che per ogni strumento codifico l’orario di inizio e fine da lunedì al venerdì per quei giorni lì.

    con quelle condizioni di entrata-uscita sia long che short.

    apre prende profitto e chiude la posizione a mercato alla chiusura della candela;sia LONG CHE SHORT.

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

Qualcuno mi può dire dove sto sbagliando nel codice ?


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
iceman89 @iceman89 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by iceman89
8 years, 4 months ago.

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