Variabile utente non funziona

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #113765 quote
    carlod
    Participant
    New

    L’intendimente dell’ uso della variabile di stato PreventBuy e’ quello di bloccare il buy dopo un sell per Target raggiunto

    Il codice seguente non effettua nessun Buy e nessun Sell, sembra che la variabile di stato non funzioni

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    
    ONCE PreventBuy = 0
    
    indicator1 = Supertrend[3,10]
    
    // Trend following
    IF LONGONMARKET = 0 AND close > indicator1 THEN
    IF PreventBuy = 0 THEN
    // Attention: removing the next line the code produce buys and sells. Why?
    PreventBuy = 1
    BUY 5000 cash roundedup AT MARKET
    ENDIF
    ENDIF
    
    // Condizioni per uscire da posizioni long
    IF LONGONMARKET = 1 AND close < indicator1 THEN
    PreventBuy = 0
    SELL AT MARKET
    ENDIF
    
    SET TARGET %PROFIT 20
    #113769 quote
    robertogozzi
    Moderator
    Master

    >> Per chiarezza dei messaggi sul Forum di Prorealcode, separate le parti del vostro codice usando il pulsante per l’inserimento del testo del codice. <<
    🙂

    #113777 quote
    robertogozzi
    Moderator
    Master

    Il codice va bene, l’unica cosa che potrebbe causare un errore in fase di primo acquisto e quindi non entrare a mercato, lasciando però il flag settato, è 5000, prova a mettere 50 o 5.

    #113792 quote
    carlod
    Participant
    New

    Roberto, ti ringrazio del sollecito riscontro.

    Non ho capito come mai non faceva un primo buy/sell, comunque c’era un baco nel mio programma, di sotto la versione corretta che funziona.

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

Variabile utente non funziona


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
carlod @carlod Participant
Summary

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

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