solo direzione long

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #239480 quote
    Antonio Garbinesi
    Participant
    Average
    Defparam cumulateorders = False
    
    possize = 1
    
    StochUpperLimit = 90
    StochLowerLimit = 20
    StochConsolidationPeriod = 2
    
    StochPeriods = 18
    StochK = 2
    StochD = 6
    
    StochSignal = Stochastic[StochPeriods,StochK](close)
    StochMain = average[StochD](StochSignal)
    
    RSI2 = RSI[2](close)
    
    RSIUpperLimit = 95
    RSILowerLimit = 5
    
    RSILimit = 4
    
    once Stoch = 0
    once StochCounter = 0
    once RSICounter = 0
    once RSICounterAdj = 0
    once LastRSI = 50
    
    If Stoch = 0 and lowest[StochConsolidationPeriod](StochSignal) < StochLowerLimit and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then
    Stoch = -1
    StochCounter = 0
    ElsIf Stoch = 0 and highest[StochConsolidationPeriod](StochSignal) > StochUpperLimit and StochSignal[1] >= StochMain[1] and StochSignal < StochMain Then
    Stoch = 1
    StochCounter = 0
    EndIf
    
    StochCounter = StochCounter + 1//questo si aggiorna sempre essendo fuori da qualsisasi if lui si aggiorna sempre
    
    If onmarket = 0 and Stoch= -1 and StochCounter > 1 and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then
    Buy possize contract at market
    StochCounter = 0
    RSICounter = 0
    RSICounterAdj = 0
    LastRSI = 50
    ElsIf onmarket = 0 and Stoch = 1 and StochCounter > 1 and StochSignal[1] >= StochMain[1] and StochSignal < StochMain Then
    Sellshort possize contract at market
    StochCounter = 0
    RSICounter = 0
    RSICounterAdj = 0
    LastRSI = 50
    EndIf
    
    If longonmarket and RSI2[1] >= RSIUpperLimit and RSI2 < RSIUpperLimit Then
    RSICounter = RSICounter + 1
    If highest[8](RSI2) < LastRSI Then
    RSICounterAdj = RSICounterAdj + 1
    EndIf
    LastRSI = highest[8](RSI2)
    ElsIf shortonmarket and RSI2[1] <= RSILowerLimit and RSI2 > RSILowerLimit Then
    RSICounter = RSICounter + 1
    If lowest[8](RSI2) > LastRSI Then
    RSICounterAdj = RSICounterAdj + 1
    EndIf
    LastRSI = lowest[8](RSI2)
    EndIf
    
    If longonmarket and RSI2[1] < RSIUpperLimit and RSI2 >= RSIUpperLimit and RSICounter >= RSILimit-RSICounterAdj Then
    sell at market
    Stoch = 0
    ElsIf shortonmarket and RSI2[1] > RSILowerLimit and RSI2 <= RSILowerLimit and RSICounter >= RSILimit-RSICounterAdj Then
    exitshort at market
    Stoch = 0
    EndIf
    #239481 quote
    robertogozzi
    Moderator
    Master

    Questo va solo Long (ho dovuto fare un bel pò di prove per capire cosa togliere e modificare), verifica che siano operazioni aperte correttamente rispetto al codice che hai postato:

    Defparam cumulateorders = False
    
    possize = 1
    
    StochUpperLimit = 90
    StochLowerLimit = 20
    StochConsolidationPeriod = 2
    
    StochPeriods = 18
    StochK = 2
    StochD = 6
    
    StochSignal = Stochastic[StochPeriods,StochK](close)
    StochMain = average[StochD](StochSignal)
    
    RSI2 = RSI[2](close)
    
    RSIUpperLimit = 95
    RSILowerLimit = 5
    
    RSILimit = 4
    
    once Stoch = 0
    once StochCounter = 0
    once RSICounter = 0
    once RSICounterAdj = 0
    once LastRSI = 50
    
    If Stoch = 0 and lowest[StochConsolidationPeriod](StochSignal) < StochLowerLimit and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then
    Stoch = -1
    StochCounter = 0
    ElsIf Stoch = 0 and highest[StochConsolidationPeriod](StochSignal) > StochUpperLimit and StochSignal[1] >= StochMain[1] and StochSignal < StochMain Then
    Stoch = 1
    StochCounter = 0
    EndIf
    
    StochCounter = StochCounter + 1//questo si aggiorna sempre essendo fuori da qualsisasi if lui si aggiorna sempre
    
    If onmarket = 0 and Stoch= -1 and StochCounter > 1 and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then
    Buy possize contract at market
    StochCounter = 0
    RSICounter = 0
    RSICounterAdj = 0
    LastRSI = 50
    ElsIf onmarket = 0 and Stoch = 1 and StochCounter > 1 and StochSignal[1] >= StochMain[1] and StochSignal < StochMain Then
    //Sellshort possize contract at market
    //StochCounter = 0
    //RSICounter = 0
    //RSICounterAdj = 0
    //LastRSI = 50
    EndIf
    
    If longonmarket and RSI2[1] >= RSIUpperLimit and RSI2 < RSIUpperLimit Then
    RSICounter = RSICounter + 1
    If highest[8](RSI2) < LastRSI Then
    RSICounterAdj = RSICounterAdj + 1
    EndIf
    LastRSI = highest[8](RSI2)
    ElsIf not onmarket and RSI2[1] <= RSILowerLimit and RSI2 > RSILowerLimit Then
    RSICounter = RSICounter + 1
    If lowest[8](RSI2) > LastRSI Then
    RSICounterAdj = RSICounterAdj + 1
    EndIf
    LastRSI = lowest[8](RSI2)
    EndIf
    
    If longonmarket and RSI2[1] < RSIUpperLimit and RSI2 >= RSIUpperLimit and RSICounter >= RSILimit-RSICounterAdj Then
    sell at market
    Stoch = 0
    ElsIf not onmarket and RSI2[1] > RSILowerLimit and RSI2 <= RSILowerLimit and RSICounter >= RSILimit-RSICounterAdj Then
    //exitshort at market
    Stoch = 0
    EndIf
    #239524 quote
    Antonio Garbinesi
    Participant
    Average
    //Defparam cumulateorders = False
    
    possize = 1
    
    StochUpperLimit = 90
    StochLowerLimit = 20
    StochConsolidationPeriod = 2
    
    StochPeriods = 18
    StochK = 2
    StochD = 6
    
    StochSignal = Stochastic[StochPeriods,StochK](close)
    StochMain = average[StochD](StochSignal)
    
    
    if not LONGONMARKET THEN
    Stoch =0
    endif
    
    If Stoch = 0 and lowest[StochConsolidationPeriod](StochSignal) < StochLowerLimit and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then
    Stoch = -1
    
    EndIf
    
    a=0
    // Solo condizione per acquisto
    If Stoch= -1  and StochSignal[1] <= StochMain[1] and StochSignal > StochMain and lowest[StochConsolidationPeriod](StochSignal) < StochLowerLimit Then
    a=1
    Buy possize contract at market
    
    EndIf
    
    SET TARGET %PROFIT 10
    SET STOP %LOSS 5
    
    
    
    come posso resettare stoch a 0 ? ho provato come da codice a inserire la condizione "if not longonmarket " ma il sistema entra ed esce subito 
    
    Screenshot-2024-10-26-180339.png Screenshot-2024-10-26-180339.png
    #239529 quote
    robertogozzi
    Moderator
    Master

    Metti queste 3 righe così:

    //if not LONGONMARKET THEN
    Stoch =0
    //endif

    ovviamente le due righe commentate le puoi togliere, se preferisci.

    #239555 quote
    Antonio Garbinesi
    Participant
    Average

    grazie Roberto ma non risolve perche mi rimette su ogni barra stoch=0 e quindi non cambia niente , stoch dovrebbe restare impostato a -1 fin quando resto a mercato e poi tornare a 0 per poter di nuovo il set up di riga 21

    #239556 quote
    Antonio Garbinesi
    Participant
    Average

    c e anche un altra cosa che non capisco ,perche mi entra a quel livello li evidenziato mentre l entrata dovrebbe essere a mercato quindi all apertura della barra successiva

    Screenshot-2024-10-27-093045.png Screenshot-2024-10-27-093045.png
    #239574 quote
    robertogozzi
    Moderator
    Master

    Nel tuo codice https://www.prorealcode.com/topic/solo-direzione-long/#post-239524 STOCH resta a -1 quando è a mercato e va a 0 quando non è a mercato.

    Io ho solo cambiato queste due righe:

    SET TARGET %PROFIT 1
    SET STOP   %LOSS   0.5

    perché altrimenti faceva operazioni molto lunghe e restava SEMPRE a mercato.

    #239575 quote
    robertogozzi
    Moderator
    Master

    Aggiungi questa riga per vedere il prezzo:

    graphonprice PositionPrice
    #239588 quote
    Antonio Garbinesi
    Participant
    Average

    Ho notato che questo, come altri sistemi che dovrebbero entrare “a mercato” in realtà entrano ad un livello superiore della apertura della barra, cosa che pero succede solo con azioni mentre con indici usando lo stesso sistema non avviene, il dubbio è che prorealtime abbia inserito i livelli di bid e ask ed usa quelli come entrata a mercato e non più l apertura della barra e quindi dove lo spread tra bid e ask è più marcato (appunto i titoli azionari rispetto ad esempio agli indici) l entrata a mercato avvenga ad un livello diverso dalla apertura della  barra.

    #239629 quote
    robertogozzi
    Moderator
    Master

    Non so dirti niente in merito. Prova a chiederlo direttamente a ProRealTime.

    #239938 quote
    GraHal
    Participant
    Master

    dovrebbe entrare “nel mercato” in realtà entrare a un livello più alto rispetto all’apertura della barra

    Ciò che vediamo come prezzo di apertura è il prezzo medio tra bid e ask.

    “Acquista a lungo sul mercato” verrebbe eseguito a un prezzo (leggermente) più alto rispetto al prezzo di apertura che vediamo su una candela.

    Nei miei grafici ho sempre l’indicatore “Banda bid-ask”: questo dimostra ciò che sto dicendo sopra.  

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

solo direzione long


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by GraHal
1 year, 4 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/25/2024
Status: Active
Attachments: 2 files
Logo Logo
Loading...