Stop Loss e Target Profit basati sui valori di prezzo

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #116576 quote
    GuidozGuidoz
    Participant
    New

    Dato il seguente listato

    DEFPARAM CumulateOrders = False
     
    IF Low < Lowest [22] (low[1]) THEN
       PrezzoStopLoss = low
       BUY 3000 CASH AT MARKET
    ENDIF
     
    SET STOP $LOSS ABS(tradeprice - PrezzoStopLoss)
    SET TARGET $PROFIT ABS(tradeprice - PrezzoStopLoss)

    Vorrei poter fissare lo stop loss e il target profit sul prezzo effettivo dell’azione, è possibile? Ho provato con

    SET STOP LOSS PrezzoStopLoss 
    SET TARGET PROFIT (tradeprice + ABS(tradeprice - PrezzoStopLoss))

    ma la posizione non si chiude mai. Grazie.

    #116578 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Le tue ultime due righe richiedono NON un prezzo, tipo LOW, ma una differenza di prezzo, tipo CLOSE-LOW.

    #116902 quote
    GuidozGuidoz
    Participant
    New

    Chiarissimo come sempre Roberto, grazie

    #119146 quote
    Gabriele EandiGabriele Eandi
    Participant
    Junior

    Buongiorno, avrei bisogno anche io di una delucidazione sullo Stop Loss:

    A = Call “all_ts”
    L10=lowest[10](low)
    H10=highest[10](high)
    
    if longonmarket then
    sell at market tomorrowopen
    endif
    
    if shortonmarket then
    exitshort at market tomorrowopen
    endif
    
    if a > 0 then
    buy a shares at market tomorrowopen
    SET STOP pLOSS TRADEPRICE-TRADEPRICE-L10
    endif
    
    if a < 0 then
    sellshort abs(a) shares at market tomorrowopen
    SET STOP pLOSS TRADEPRICE+H10-TRADEPRICE
    endif
    graph TRADEPRICE-(TRADEPRICE-L10)
    graph TRADEPRICE+(H10-TRADEPRICE)

    inserito in questo modo, non me lo prende mai, sapete dirmi dove sbaglio? grazie!

    #119152 quote
    robertogozzirobertogozzi
    Moderator
    Legend

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

    Innanzitutto preciso che la parola riservata TOMORROWOPEN (come pure NEXTBAROPEN) è obsoleta e non fa niente, per cui puoi anche non metterla.

    Alle righe 15 e 20 hai un’espressione che dice “100 – 100 -10” puoi scrivere direttamente -10, non hai visto con GRAPH (che hai messo) che ti da un valore negativo?

    Come può arrivare allo stop loss se questo è, ad esempio sul Dax, -13,500 ?

    Tieni presente che pLOSS vuole un numero espresso in pips, nel caso del DAX è ininfluente, ma sulle valute no, il valore accando dovrebbe essere moltiplicato * PIPSIZE per avere un valore corretto, ed eventualmente usa ABS()  con il valore o l’espressione tra le parentesi tonde, per essere certo che il valore non sia negativo.

    Inoltre TRADEPRICE è conosciuto solo dalla barra successiva, perché prima di entrare a mercato NON sa a che prezzo entrerà, a causa di gaps o slippage. Conviene usare CLOSE quando si entra a mercato.

    Tu vuoi uno stop loss che sia la differenza tra il prezzo d’entrata ed il massimo o il minimo trovato all’inizio alle righe 2-3.

    Questo è il codice (non l’ho provato perché non hai postato l’indicatore):

    A = Call “all_ts”
    L10=lowest[10](low)
    H10=highest[10](high)
     
    if longonmarket then
       sell at market
    endif
     
    if shortonmarket then
       exitshort at market
    endif
     
    if a > 0 then
       buy a shares at market
       SET STOP pLOSS abs(close-L10) * pipsize
    endif
    
    if a < 0 then
       sellshort abs(a) shares at market
       SET STOP pLOSS abs(H10-close) * pipsize
    endif
    graph abs(close-L10) * pipsize
    graph abs(H10-close) * pipsize
    #119232 quote
    Gabriele EandiGabriele Eandi
    Participant
    Junior

    ho capito! grazie

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

Stop Loss e Target Profit basati sui valori di prezzo


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Guidoz @guidoz Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by Gabriele EandiGabriele Eandi
6 years, 7 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 01/12/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...