entry dopo X candele dalla prima condizione

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #110276 quote
    agamennone magamennone 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
    robertogozzirobertogozzi
    Moderator
    Legend

    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.
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

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 robertogozzirobertogozzi
6 years, 11 months ago.

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