entry dopo X candele dalla prima condizione

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #110276 quote
    agamennone m
    Participant
    Junior

    ciao,vorrei un aiuto per la programmazione

    che funzione uso per attendere una seconda condizione dopo X candele dalla prima condizione?

    ad esempio un ts che effettua l’entry se lo stocastico inverte entro 3 candele dopo aver toccato una banda di Bollinger…

    spero di essermi spiegato.

    grazie

    #110279 quote
    robertogozzi
    Moderator
    Master

    Eccolo, provalo e fammi sapere (l’ho provato solo per la correttezza sintattica):

    ONCE BBtouchL = 0
    ONCE BBtouchS = 0
    ONCE Count    = 0
    ONCE MaxBars  = 3
    //
    // setup Bollinger Bands
    BBVal   = 20                                    //20   periods BB
    BBdev   = 2.0                                   //2.0  deviation BB
    BBavg   = average[BBval,0](close)               //BB mean (middle line)
    BollUP  = BBavg + ((std[BBval](close)) * BBdev) //BB Upper Band
    BollDN  = BBavg - ((std[BBval](close)) * BBdev) //BB Lower Band
    //
    IF count = MaxBars THEN
       BBtouchL = 0
       BBtouchS = 0
       Count    = 0
    ENDIF
    //
    // setup Stocastico
    StocK   = Stochastic[10,3](close)               //Linea K
    StocD   = Average[3,0](StocK)                   //Linea D
    //
    // setup consizione LONG
    //
    BBtouchL = (low <= BollDN)
    IF BBtouchL THEN
       BBtouchS = 0
       IF BBtouchL[1] = 0 THEN
          Count = 0
       ENDIF
    ENDIF
    IF BBtouchL THEN
       Count           = Count + 1
       InversioneLONG  = StocK > StocD AND StocK > 20
    ENDIF
    //
    // setup condizione SHORT
    //
    BBtouchS = (high >= BollUP)
    IF BBtouchS THEN
       BBtouchL = 0
       IF BBtouchS[1] = 0 THEN
          Count = 0
       ENDIF
    ENDIF
    IF BBtouchS THEN
       Count           = Count + 1
       InversioneSHORT = StocK < StocD AND StocK < 80
    ENDIF
    //
    IF OnMarket THEN
       BBtouchL = 0
       BBtouchS = 0
       Count    = 0
    ENDIF
    //
    // Apertura posizione LONG
    IF BBtouchL AND InversioneLONG  AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    //
    // Apertura posizione SHORT
    IF BBtouchS AND InversioneSHORT AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET TARGET pPROFIT 100
    SET STOP   pLOSS   50
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

entry dopo X candele dalla prima condizione


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
6 years, 4 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/15/2019
Status: Active
Attachments: No files
Logo Logo
Loading...