Ichimoku – kijun cross – problemi con chiusura posizione

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #69070 quote
    Gabrielcin
    Participant
    Junior

    ho cercato di integrare le bande di bollinger al sistema ma purtroppo mi da risultati disastrosi. Ti posso chiedere se lo puoi provare e mi dici? probabilmente sbaglio io. Ti posto il codice che ho modificato, inoltre noto che durante la lateralità il sistema continua a lavorare allo stesso modo

    // trading sistem basato su ICHIMOKU - 1 ORA
    //  TESTING
    //******************************************
    //****** INGRESSO LONG : PREZZO OVER KIJUN
    //                       PREZZO OVER TENKAN
    //*****CHIUSURA LONG : PREZZO UNDER KIJUN
    //                     PREZZO UNDER TENKAN
    //******************************************
    // *******INGRESSO SHORT : PREZZO UNDER KIJUN
    //                         PREZZO UNDER TENKAN
    //******* CHIUSURA SHORT : PREZZO OVER KIJUN
    //                         PREZZO OVER TENKAN
    //******************************************
    
    
    //tempo =(time=>060000 and time <=110000)
    
    a = BollingerUp[40](close)
    b = BollingerDown[40](close)
    B1Range = a - b
     
    c = BollingerUp[20](close)
    d = BollingerDown[20](close)
    B2Range = c - d
     
    if B2Range < (B1Range/2) then
    NoTrade = 1
    else
    NoTrade = 0
    endif
    
    
    //ichimoku
    
    Tenkansen = (highest[9](close)+lowest[9](close))/2
    Kijunsen = (highest[26](close)+lowest[26](close))/2
    
    //SSpanA = (tenkansen[28]+kijunsen[28])/2
    //SSpanB = (highest[119](high[28])+lowest[119](low[28]))/2
     
    //Chikou = close[28]
    
    //condizioni long
    kijunlong = close crosses over kijunsen
    tenkanlong = close crosses over tenkansen
    
    //condizioni short
    kijunshort = close crosses under kijunsen
    tenkanshort = close crosses under tenkansen
    
    //ingresso long
    if not longonmarket and Notrade=0 then
    if kijunlong  then
    buy 1 contract at market
    endif
    if tenkanlong and tenkansen > kijunsen then
    buy 1 contract at market
    endif
    endif
    
    //uscita long
    if longonmarket then
    if kijunshort then
    sell at market
    endif
    if tenkanshort and tenkansen > kijunsen then
    sell at market
    endif
    endif
    
    //ingresso short
    if not shortonmarket and notrade=0 then
    if kijunshort then
    sellshort 1 contract at market
    endif
    if tenkanshort and tenkansen < kijunsen then
    sellshort 1 contract at market
    endif
    endif
    
    //uscita short
    if shortonmarket then
    if kijunlong then
    exitshort at market
    endif
    if tenkanlong and tenkansen < kijunsen then
    exitshort at market
    endif
    endif
    #69077 quote
    robertogozzi
    Moderator
    Master

    Non sono certo la soluzione definitiva, prova a mettere le due  bande sul grafico sul quale provi la strategia e vedi se sono in un range o meno, magari devi aggiustare un pò i valori delle bande o la deviazione.

    Puoi anche abbinare alle bande quel codice che ho pubblicato sulla lateralità per vedere se, combinando le due cose, ottieni risultati migliori.

    Un altro modo per verificare la lateralità è quella di vedere se una certa media mobile alterna brevi fasi in cui va su ad altre in cui va giù, facendo una specie di zigzag. E’ chiro che per determinare che siamo in un range devono passare alcune candele, per cui arrivi sempre in ritardo rispetto al prezzo. L’importante è che riesca, alla fine, a risparmiarti qualche trade, non certo ad eliminarli tutti quelli che vengono aperti in una fase laterale.

    Cercando sul forum LATERALITA o RANGE o CONTRACTION o CONTRAZIONE magari riesci a trovare altri esempi più o meno validi. Puoi cercare anche sul web se trovi qualcosa su come identificare una contrazione e magari possiamo codificarlo.

    #69197 quote
    Gabrielcin
    Participant
    Junior

    ho trovato questo codice che sembri funzionare abbastanza bene riguardo le bande di bollinger. Vediamo se ho capito bene, è nella variabile “ca3” che il sistema capisce se siamo in presenza di trend o meno?

    // % Bollinger en tendance
    
    Defparam cumulateorders = false
    
    // Taille des positions
    n = 1
    
    // Indicateur % Bollinger : pB
    // Paramètres 5/1
    BollInf = Average[5](close)-1*std[5](close)
    BollSup = Average[5](close)+1*std[5](close)
    pB = (close - BollInf) / (BollSup - BollInf)
    
    // ACHAT
    ca1 = close > average[100](close)
    ca2 = average[20](close) > average[200](close)
    ca3 = pB[1] < 0.2 and pB < 0.2
    
    IF ca1 and ca2 and ca3 THEN
     buy n shares at market
    ENDIF
    
    // SORTIE ACHAT
    IF pB crosses over 1 THEN
     sell at market
    ENDIF
    #69206 quote
    robertogozzi
    Moderator
    Master

    Mi sembra un codice poco efficace, intanto le bande sono molto strette, 5 rispetto allo standard di 20, poi non capisco bene cosa abbia voluto fare con il calcolo di pB, ma in ogni caso, applicate sul grafico mi pare dia molti  falsisegnali.

    Ad ogni modo, se metti le BB sul grafico puoi vedere le caratteristiche quando entri in un range, in particolare quandi entrambe si contraggono e quando si espandono, come da foto allegata.

    Per tornare al codice di cui sopra (a parte i settaggi che ciascuno preferisce), per vedere se si contraggono si scrive:

    Contrazione = BollInf > BollInf[1] AND BollSup < BollSup[1]

    come vedi si confrontano i due limiti, quello superiore deve essere < alla candela precedente e quello inferiore deve essere > della candela precedente.

    L’opposto per l’espansione

    Espansione = BollInf < BollInf[1] AND BollSup > BollSup[1]
    #69208 quote
    Gabrielcin
    Participant
    Junior

    ho capito, il tuo esempio mi è di molto aiuto. Purtroppo però mi sto confondendo e non sto riuscendo più a capire come integrarlo con il mio codice. Se riuscissi a mettere insieme i due codici potrebbe risultare una buona tecnica sia per lo scalping che per il lungo periodo

    #69219 quote
    robertogozzi
    Moderator
    Master

    Ho modificato io il tuo codice di cui sopra, inserendo la parte evidenziate all’inizio tra le due righe “/////////////////////////////////////////////////” e poi ho modificato le righe per l’entrata LONG e SHORT. Prova e fammi sapere sze funziona correttamente la parte logica del codice, non tanto la strategia, che dovrai aggiustare te.

    // trading sistem basato su ICHIMOKU - 1 ORA
    //  TESTING
    //******************************************
    //****** INGRESSO LONG : PREZZO OVER KIJUN
    //                       PREZZO OVER TENKAN
    //*****CHIUSURA LONG : PREZZO UNDER KIJUN
    //                     PREZZO UNDER TENKAN
    //******************************************
    // *******INGRESSO SHORT : PREZZO UNDER KIJUN
    //                         PREZZO UNDER TENKAN
    //******* CHIUSURA SHORT : PREZZO OVER KIJUN
    //                         PREZZO OVER TENKAN
    //******************************************
    
    ////////////////////////////////////////////////////////////////////////////////
    ONCE Contrazione = 0
    ONCE Espansione  = 0
    BollInf = Average[5](close)-1*std[5](close)
    BollSup = Average[5](close)+1*std[5](close)
    Contrae = BollInf > BollInf[1] AND BollSup < BollSup[1]
    Espande = BollInf < BollInf[1] AND BollSup > BollSup[1]
    IF Contrae THEN
    Contrazione = 1
    Espansione  = 0
    ENDIF
    IF Espande THEN
    Contrazione = 0
    Espansione  = 1
    ENDIF
    ////////////////////////////////////////////////////////////////////////////////
    
    //tempo =(time=>060000 and time <=110000)
     
    a = BollingerUp[40](close)
    b = BollingerDown[40](close)
    B1Range = a - b
     
    c = BollingerUp[20](close)
    d = BollingerDown[20](close)
    B2Range = c - d
     
    if B2Range < (B1Range/2) then
    NoTrade = 1
    else
    NoTrade = 0
    endif
     
     
    //ichimoku
     
    Tenkansen = (highest[9](close)+lowest[9](close))/2
    Kijunsen = (highest[26](close)+lowest[26](close))/2
     
    //SSpanA = (tenkansen[28]+kijunsen[28])/2
    //SSpanB = (highest[119](high[28])+lowest[119](low[28]))/2
     
    //Chikou = close[28]
     
    //condizioni long
    kijunlong = close crosses over kijunsen
    tenkanlong = close crosses over tenkansen
     
    //condizioni short
    kijunshort = close crosses under kijunsen
    tenkanshort = close crosses under tenkansen
     
    //ingresso long
    if not longonmarket and Notrade=0 and not Contrazione then
    if kijunlong  then
    buy 1 contract at market
    endif
    if tenkanlong and tenkansen > kijunsen then
    buy 1 contract at market
    endif
    endif
     
    //uscita long
    if longonmarket then
    if kijunshort then
    sell at market
    endif
    if tenkanshort and tenkansen > kijunsen then
    sell at market
    endif
    endif
     
    //ingresso short
    if not shortonmarket and notrade=0 and not Contrazione then
    if kijunshort then
    sellshort 1 contract at market
    endif
    if tenkanshort and tenkansen < kijunsen then
    sellshort 1 contract at market
    endif
    endif
     
    //uscita short
    if shortonmarket then
    if kijunlong then
    exitshort at market
    endif
    if tenkanlong and tenkansen < kijunsen then
    exitshort at market
    endif
    endif
    #69220 quote
    robertogozzi
    Moderator
    Master

    Le righe 24 e 28 commentale se ti segnala che quella variabile non viene mai usata.

    #69226 quote
    Gabrielcin
    Participant
    Junior

    ho testato il codice e sembri funzioni, entra in posizione come vorrei io. Da migliorare le uscite ovviamente. Sembra che la lateralità venga filtrata un po di più. Ti posto i risultati.

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.

Ichimoku – kijun cross – problemi con chiusura posizione


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Gabrielcin @gabrielcin Participant
Summary

This topic contains 22 replies,
has 2 voices, and was last updated by Gabrielcin
7 years, 9 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/21/2018
Status: Active
Attachments: 4 files
Logo Logo
Loading...