Indicatore sulla equity

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #122940 quote
    Gabriele Eandi
    Participant
    Junior

    Buongiorno, mi scuso in anticipo se ci fossero già dei post sull’argomento. Io vorrei creare un indicatore che lavori sulla equity di un mio TS, vorrei in pratica avere il calcolo automatico del profitto medio delle mie operazioni. Il TS in oggetto è in realtà un indicatore che restituisce 1 per Long il giorno dopo e 2 per short il giorno dopo, ho quindi creato scritto questo codice:

    a = CALL "@all"[xxx]
    
    if a[2] > 0 then
    Z = a[2]*(open-open[1])
    elsif a[2] < 0 then
    Z = a[2]*(open-open[1])
    else
    Z = 0
    endif
    
    return average[30](z)

    però non funziona perchè fa la media degli ultimi 30 giorni, calcolando nella media anche gli 0 da posizione Flat.

    Qualcuno mi aiuta?

    Grazie!

    #122941 quote
    Gabriele Eandi
    Participant
    Junior

    mi scuso correggo (non so se si può modificare il post) il TS da -1 per lo Short, non 2

    Sorry

    #122962 quote
    robertogozzi
    Moderator
    Master

    Purtroppo con AVERAGE va semprea prendere le ultime 30 candele.

    Essendo una media semplice si può sostituire con:

    ONCE Conto  = 0
    ONCE Prima  = 0
    ONCE Totale = 0
    ONCE Media  = 0
    a = CALL "@all"[xxx]
    if a[2] > 0 then
       Z = a[2]*(open-open[1])
    elsif a[2] < 0 then
       Z = a[2]*(open-open[1])
    else
       Z = 0
    endif
    if Z then
       If Prima = 0 then
          Prima  = Z
          Totale = Z
          Conto  = 1
       else
          Conto  = Conto  + 1
          Totale = Totale + Z
          IF Conto >= 30 THEN
             Media  = Totale / 30
             Totale = Totale - Prima
             Prima  = Z
          ENDIF
       endif
    endif
    return Media

    (non l’ho provato)

    #122969 quote
    Gabriele Eandi
    Participant
    Junior

    Funziona!! grazie

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

Indicatore sulla equity


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
Summary

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

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 03/22/2020
Status: Active
Attachments: No files
Logo Logo
Loading...