Strategia 1 Minuto In controtendenza Movimento

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #232685 quote
    SimonSimon
    Participant
    New

    Buongiorno Roberto,

    chiedo cortesemente aiuto per scrivere questa strategia:

    Timeframe: 1 minuto

    Strategia:

    1. Rileva l’escursione massima delle ultime 2 candele.
    2. Se l’escursione è superiore allo 0.005%:
      • Se l’escursione è negativa, compra 1 contratto con target price al prezzo massimo delle 2 ultime candele.
      • Se l’escursione è positiva, vende 1 contratto con target price al prezzo minimo delle 2 ultime candele.
    3. Il codice deve impedire l’apertura di una posizione inversa quando già sul mercato.

    Grazie mille per il tuo aiuto.

    Cordiali saluti, Simone

    #232738 quote
    MaoRai54MaoRai54
    Participant
    Master

    scusa ma cosa intendi per “escursione”.

    intendi l’ampiezza della candela tra high e low ?

    #232739 quote
    MaoRai54MaoRai54
    Participant
    Master

    @ Roberto

    così è giusto???

    DEFPARAM CUMULATEORDERS =FALSE

    TIMEFRAME (2 MINUTE)

    CC=close[1]
    OO=open[1]

    timeframe (default)

    if not onmarket and CC>OO and CC/OO>FX then
    sellshort 1 contract at market
    endif

    if not onmarket and CC<OO and OO/CC>FX then
    buy 1 contract at market
    endif

    timeframe (default)

    if shortonmarket then
    exitshort at CC limit
    endif

    if longonmarket then
    sell at OO limit
    endif

    #232740 quote
    MaoRai54MaoRai54
    Participant
    Master

    SCUSATE L’ERRORE

    QUESTO DOVREBBE ESSERE OK.

    DEFPARAM CUMULATEORDERS =FALSE

    TIMEFRAME (15 MINUTE)

    CC=close[1]
    OO=open[1]

    timeframe (default)

    if not onmarket and CC>OO and ((CC-OO)/CC)*100>FX then
    sellshort 1 contract at market
    endif
    if not onmarket and CC<OO and ((OO-CC)/OO)*100>FX then
    buy 1 contract at market
    endif

    timeframe (default)

    if shortonmarket then
    exitshort at CC limit
    endif
    if longonmarket then
    sell at OO limit
    endif

    #232759 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Mi sembra più corretta questa versione (non ho previsto un’uscita perché non richiesta):

    DEFPARAM CUMULATEORDERS =FALSE
    Massimo = highest[2](high)
    Minimo  = lowest[2](low)
    Rialzo  = close > open
    Ribasso = close < open
    IF Rialzo THEN
       Escursione = range
    ELSIF Ribasso THEN
       Escursione = -range
    ENDIF
    CondS   = (summation[2](Escursione > 0) = 2)
    CondL   = (summation[2](Escursione < 0) = 2)
    if not onmarket then
       if CondL THEN
          BUY 1 contract at Market
          Set Target PROFIT Massimo - close
       elsif CondS THEN
          SELLSHORT 1 contract at Market
          Set Target PROFIT close - Minimo
       endif
    endif

    il timeframe non l’ho specificato in quanto viene usato solo 1 minuto, quindi non serve.

    GraHal thanked this post
    #232800 quote
    SimonSimon
    Participant
    New

    Buongiorno,

    desidero ringraziare tutti per l’aiuto.

    Scusate ma ho scritto la richiesta in maniera errata e con i vostri suggerimenti non riesco a modificare il codice per ottenere quello che vorrei, quindi riformulo:

    Strategia:

    1. Rileva l’escursione massima delle ultime N(Variabile) candele.
    2. Se l’escursione è superiore alla Percentuale(variabile), procede così:
      • Se l’escursione è negativa, compra 1 contratto con target price al prezzo massimo delle N candele * coeff (variabile).
      • Se l’escursione è positiva, vende 1 contratto con target price al prezzo minimo delle N candele * coeff (variabile).
    3. Il codice deve impedire l’apertura di una posizione inversa quando già sul mercato.
    4. Dopo un trade, il sistema deve entrare in pausa per PausaNBarre(variabile) e poi riprendere.

    Lo scopo è di rilevare movimenti più o meno veloci e acquistare o vendere in controtendenza in corrispondenza dei massimi o dei minimi del movimento.

    Grazie mille per il vostro aiuto.

    grafico.jpg grafico.jpg
    #234699 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ecco:

    DEFPARAM CUMULATEORDERS = FALSE
    ONCE N     = 20                               //20   candele lookback per escursione
    ONCE PC    = 2.5 / 100                        //2.5% percentuale
    ONCE Coeff = 5.0 / 100                        //5%   coefficiente
    ONCE Pausa = 10                               //10   candele di pausa dopo la chiusura di un'operazione
    ONCE Cont  = Pausa + 1
    Massimo    = highest[N](high)
    Minimo     = lowest[N](low)
    MaxHH      = Massimo <> Massimo[1]
    MinLL      = Minimo  <> Minimo[1]
    Escursione = Massimo - Minimo
    Esc        = Escursione > (Massimo * PC)
    IF BarsSince(MaxHH) > BarsSince(MinLL) THEN
    Escursione = Minimo - Massimo
    Esc        = abs(Escursione) > (Minimo * PC)
    ENDIF
    CondL      = Esc AND (Escursione < 0)
    CondS      = Esc AND (Escursione > 0)
    if not onmarket THEN
    IF (Cont >= Pausa) then
    if CondL THEN
    BUY 1 contract at Market
    Set Target PRICE Massimo * (1 + Coeff)
    Cont = 0
    elsif CondS THEN
    SELLSHORT 1 contract at Market
    Set Target PRICE Minimo * (1 - Coeff)
    Cont = 0
    endif
    ENDIF
    Cont = Cont + 1
    endif
    graph Cont
    //graph Esc * 100                     coloured("Red")
    //graph Escursione
    //graphonprice Massimo                coloured("Fuchsia")
    //graphonprice Minimo                 coloured("Fuchsia")
    //graphonprice Massimo * (1 + Coeff)  coloured("Blue")
    //graphonprice Minimo  * (1 - Coeff)  coloured("Red")
    Simon thanked this post
    #234704 quote
    SimonSimon
    Participant
    New

    Grazie Roberto gentilissimo!!

    #234712 quote
    MaoRai54MaoRai54
    Participant
    Master

    ciao Simon,

    l’ho testato e funziona a 1M.

    pero’ non capisco a cosa serve la pausa, visto che peggiora i risultati

    #234725 quote
    SimonSimon
    Participant
    New

    Ciao MaoRai54, l’ho inserita per decidere se  fare solo 1 operazione al giorno, oppure  ottimizzandola come variabile in alcuni casi potrebbe essere utile. Tutto comunque da testare. Saluti

Viewing 10 posts - 1 through 10 (of 10 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

Strategia 1 Minuto In controtendenza Movimento


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Simon @simontemp Participant
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by SimonSimon
2 years, 2 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 05/15/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...