Ts intraday superamento Min o Mass giorno prec.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #217303 quote
    Mauro MMauro M
    Participant
    New

    Attualmente ho solo ts Daily.

    Vorrei imparare a crearne qualcuno in intraday con time frime bassi 30 minuti 15 minuti.

    Vorrei codificare questa idea.

    Se oggi si scende sotto il minimo di ieri ( chiaramente vale l’opposto per gli short) , oggi se il mercato torna su di 100 punti compro. Stop 100 gain 300.

    #217340 quote
    MauroProMauroPro
    Participant
    Veteran

    Ti ho scritto questo sul Dax a 15 minuti (dovrebbe andare bene, ma controllalo). Con i graph vedi i masimi-minimi del giorno prima ed i livelli di entata.

    //DAX TSprova 15m [spread = 1]
    defParam cumulateOrders = false
    defParam preloadBars = 10000
    defParam flatAfter = 220000
    cTime = time >= 080000 and time <= 170000
    positionSize = 1
    //————————————————————
    deltaLong = 100*pointSize
    SLlong = 150*pointSize
    TPlong = 300*pointSize
    deltaShort = 100*pointSize
    SLshort = 150*pointSize
    TPshort = 300*pointSize
    //———————————————
    previousDayLow = dLow(1)
    entryLong = previousDayLow + deltaLong
    previousDayHigh = dHigh(1)
    entryShort = previousDayHigh – deltaShort
    //————————————————————–
    once previousDayLowReached = 0
    once previousDayHighReached = 0
    if intraDayBarIndex = 0 then
    previousDayLowReached = 0
    previousDayHighReached = 0
    endif
    if close < previousDayLow then
    previousDayLowReached = 1
    endif
    if close > previousDayHigh then
    previousDayHighReached = 1
    endif
    //————————————————————————-
    if not onMarket and cTime and previousDayLowReached then
    if close > entryLong then
    buy positionSize contracts at entryLong LIMIT
    else
    buy positionSize contracts at entryLong STOP
    set stop pLoss Sllong
    set target pProfit TPlong
    endif
    endif
    //——————————————————————–
    if not onMarket and cTime and previousDayHighReached then
    if close < entryShort then
    sellShort positionSize contracts at entryShort LIMIT
    else
    sellShort positionSize contracts at entryShort STOP
    set stop pLoss SLshort
    set target pProfit TPshort
    endif
    endif
    //———————————————————
    graphOnPrice previousDayLow coloured (255,0,0)
    graphOnPrice entryLong coloured (255,165,0)
    graphOnPrice previousDayHigh coloured(46,139,87)
    graphOnPrice entryShort coloured (0,255,127)

    Image-001.jpg Image-001.jpg
    #217350 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Va bene, i massimi e minimi del giorno precedente sono corretti  (ho controllato 2-3 operazioni soltanto, ma credo che se na vanno bene 2-3 vanno bene anche le altre).

    Ho visto che fai, molto opportunamente, la distinzione tra entrate LIMIT e STOP. Non sarebbe male assicurarsi che il prezzo, oltre ad essere maggiore o minore dell’entrata, avesse anche la distanza minima richiesta dal broker. Se, ad esempio, il broker ha stabilito un’entrata minima di, ad esempio, 8 punti, potresti scrivere le entrate LIMIT e STOP così:

    distanza = 8
    //————————————————————————-
    if not onMarket and cTime and previousDayLowReached then
       if close > (entryLong + Distanza) then
          buy positionSize contracts at entryLong LIMIT
       elsif close < (entryLong - Distanza) then
          buy positionSize contracts at entryLong STOP
       else
          // puoi lasciare vuoto ed entrerà, se ci sono le condizioni, alla candela successive, oppure
          // metti un'entrata LONG a MERCATO, per mancanza della distanza
       endif
       set stop pLoss Sllong
       set target pProfit TPlong
    endif
    //——————————————————————-
    if not onMarket and cTime and previousDayHighReached then
       if close < (entryShort - Distanza) then
          sellShort positionSize contracts at entryShort LIMIT
       elsif close > (entryShort + Distanza) then
          sellShort positionSize contracts at entryShort STOP
       else
          // puoi lasciare vuoto ed entrerà, se ci sono le condizioni, alla candela successive, oppure
          // metti un'entrata SHORT a MERCATO, per mancanza della distanza
       endif
       set stop pLoss SLshort
       set target pProfit TPshort
    endif

     

    per evitare che, se la distanza non è rispettata, la strategia venga fatta uscire (o, peggio, entri a mercato).

    x-4.jpg x-4.jpg
    #217358 quote
    MauroProMauroPro
    Participant
    Veteran

    Ho corretto il codice con i consigli di Roberto e provato un ottimizzazione dei parametri.

    //DAX 15m [spread = 1]
    defParam cumulateOrders = false
    defParam preloadBars = 10000
    defParam flatAfter = 220000
    cTime = time >= 080000 and time <= 170000
    positionSize = 1
    //————————————————————
    deltaLong = 70*pointSize // 100
    SLlong = 150*pointSize //150
    TPlong = 300*pointSize // 300

    deltaShort = 100*pointSize //100
    SLshort = 100*pointSize // 150
    TPshort = 250*pointSize // 300
    //———————————————
    previousDayLow = dLow(1)
    entryLong = previousDayLow + deltaLong
    previousDayHigh = dHigh(1)
    entryShort = previousDayHigh – deltaShort
    //————————————————————–
    once previousDayLowReached = 0
    once previousDayHighReached = 0
    if intraDayBarIndex = 0 then
    previousDayLowReached = 0
    previousDayHighReached = 0
    endif

    if close < previousDayLow then
    previousDayLowReached = 1
    endif
    if close > previousDayHigh then
    previousDayHighReached = 1
    endif
    //————————————————————————-
    maxDistance = 2*pointSize // DAX spread: 080000 – 090000 = 2 // 090000 – 173000 = 1.2
    if not onMarket and cTime and previousDayLowReached then
    if close > (entryLong + maxDistance) then
    buy positionSize contracts at entryLong LIMIT
    elsif close < (entryLong – maxDistance) then
    buy positionSize contracts at entryLong STOP
    else
    // puoi lasciare vuoto ed entrerà, se ci sono le condizioni, alla candela successive, oppure
    // metti un’entrata LONG a MERCATO, per mancanza della distanza
    endif
    set stop pLoss SLlong
    set target pProfit TPlong
    endif
    //——————————————————————–
    if not onMarket and cTime and previousDayHighReached and dayOfWeek <> 1 then // LUNEDI ESCLUSO PER LO SHORT
    if close < (entryShort – maxDistance) then
    sellShort positionSize contracts at entryShort LIMIT
    elsif close > (entryShort + maxDistance) then
    sellShort positionSize contracts at entryShort STOP
    else
    // puoi lasciare vuoto ed entrerà, se ci sono le condizioni, alla candela successive, oppure
    // metti un’entrata SHORT a MERCATO, per mancanza della distanza
    endif
    set stop pLoss SLshort
    set target pProfit TPshort
    endif
    //———————————————————
    graphOnPrice previousDayLow coloured (255,0,0)
    graphOnPrice entryLong coloured (240,128,128)
    graphOnPrice previousDayHigh coloured(0,201,87)
    graphOnPrice entryShort coloured (192,255,62)

    Image-001-1.jpg Image-001-1.jpg
    #217395 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    La distanza è diversa dallo spread, varia da strumento a strumento, credo che di base per il DAX sia di 6-7  pip, ma durante la giornata, se c’è volatilità, viene aumentata a discrezione del broker e può arrivare ancghe a 10+ pip.  Devi verificare sul sito del broker qual’è.

    Io generalmente metto 10 pip, in questo modo è quasi sempre nei limiti imposti e solo molto raramente una strategia viene interrotta per non averli rispettati.

    #217400 quote
    Mauro MMauro M
    Participant
    New

    Ti ringrazio Roberto 🙏

    #217401 quote
    Mauro MMauro M
    Participant
    New

    Grazie MauroPro

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

Ts intraday superamento Min o Mass giorno prec.


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Mauro M @mauro-m Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by Mauro MMauro M
3 years, 2 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 07/05/2023
Status: Active
Attachments: 3 files
ProRealCode ProRealCode
Loading...