Indicatore sulla equity

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #122940 quote
    Gabriele EandiGabriele 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 EandiGabriele 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
    robertogozzirobertogozzi
    Moderator
    Legend

    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 EandiGabriele Eandi
    Participant
    Junior

    Funziona!! grazie

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

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 EandiGabriele Eandi
6 years, 6 months ago.

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