Ingresso a mercato al prezzo esatto

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #223313 quote
    Renzo
    Participant
    New

    Buongiorno, sono nuovo della community.

    Non so se qualcuno può aiutarmi: vorrei scrivere codice per prevedere che il sistema faccia ingresso a mercato ad unità di prezzo precisa, ad esempio, se il prezzo termina per “3” (come ad esempio 1503) allora compra.

    grazie mille

    #223323 quote
    robertogozzi
    Moderator
    Master

    Per entrare ad un prezzo preciso (non è mai sicuro al 100%, a causa dello slippage e volatilità) occorre un ordine STOP o LIMIT pendente per entrare ad un certo prezzo:

    PrezzoEntrata = 15200
    IF close > PrezzoEntrata  THEN
       BUY 1 Contract AT PrezzoEntrata LIMIT
    ELSIF close < PrezzoEntrata  THEN
       BUY 1 Contract AT PrezzoEntrata STOP
    ENDIF

    se, invece, vuoi entrare ad un prezzo che termina con 3, occorrono alcune semplici istruzioni di matematica:

    1. troncare i decimali arrontondando all’intero inferiore
    2. calcolare il resto (con MOD) della divisione per 10
    3. se il resto è 3, allora il prezzo termina con 3.

    Ecco il codice:

    Prezzo = floor(close,0)
    Diff   = Prezzo MOD 10
    IF Diff = 3 THEN
       // istruzioni da eseguire se il prezzo termina con 3
    ENDIF
    #223363 quote
    Renzo
    Participant
    New

    Grazie mille!

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

Ingresso a mercato al prezzo esatto


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Renzo @oronzo-gonnella Participant
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 11/07/2023
Status: Active
Attachments: No files
Logo Logo
Loading...