Background Repinta con problemas en "if"

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #69606 quote
    SoloContado
    Participant
    Veteran

    Hola,

    tengo un problema con un indicador que colorea el fondo en función de un par de condiciones. El problema es doble:

    1. por un lado, parece que repinta y no debiera
    2. por otro lado, al insertar una “flag” de compra/venta en el bucle condicional, no lo reporduce correctamente y no da señal al mismo tiempo que el fondo cambia de color (lo necesito para automatizar una estrategia).

    Agradeceré cualquier explicación y/o ayuda que me podais dar.

    El código es el siguiente:

    diflow=close-low[1]
    difhigh=close-high[1]
    
    if diflow>0 then
    vvlow=volume
    else
    if diflow<0 then
    vvlow=-volume
    else
    vvlow=0
    endif
    endif
    
    if difhigh>0 then
    vvhigh=volume
    else
    if difhigh<0 then
    vvhigh=-volume
    else
    vvhigh=0
    endif
    endif
    
    cnvlow=summation[ss](vvlow)/300
    cnvhigh=summation[ss](vvhigh)/300
    
    BandaUp=(summation[8](cnvlow-cnvhigh))/8
    BandaDown=-(summation[8](cnvlow-cnvhigh))/8
    
    REM RELATIVE VOLUME INDICATOR
    // @author LazyBear para la plataforma Tradingview, Junio 2014
    // adaptado para Prorealtime por bolsatrilera
    
    x=42// "Standard deviation length"
    //allowNegativePlots=input(false, type=bool)
    //matchVolumeColor=input(false, type=bool)
    
    av= weightedAverage[x](volume)
    sd=std[x](volume)
    
    if sd<>0 then
    relVol=(volume-av)/sd
    else
    relVol=0
    endif
    
    if 1 then
    relV=max(relVol,0)
    else
    relV=relVol
    endif
    
    // Definición de Condiciones
    
    lls=cnvlow crosses over 0 or cnvlow[1] crosses over 0 or cnvlow[2] crosses over 0 or cnvlow[3] crosses over 0
    ccs=cnvhigh crosses under 0 or cnvhigh[1] crosses under 0 or cnvhigh[2] crosses under 0 or cnvhigh[3] crosses under 0
    
    largos=lls and cnvhigh crosses over BandaDown and summation[3](RelV)>0
    cortos=ccs and cnvlow crosses under BandaUp and summation[3](RelV)>0
    lrlow=linearregressionslope[26](low)
    lrhigh=linearregressionslope[26](high)
    cond1=lrlow>0 and lrhigh>0
    cond2= lrlow<0 and lrhigh<0
    
    //Coloreado del Background
    
    if (cortos or cond2) and not cond1 then
    backgroundcolor (255,0,0,30)
    else
    if (largos or cond1) and not cond2 then
    backgroundcolor (0,255,0,30)
    endif
    ENDIF
    
    return

     

    Admin edit: modificado por el admin’ para poner en el formato correcto de PRT, por favor se usa el boton “insert PRT code” / “insertar PRT codigo” para leerlo mejor, muchas gracias

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Background Repinta con problemas en "if"


Trading General: Análisis de Mercado y Manual

New Reply
Author
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: Trading General: Análisis de Mercado y Manual
Language: Spanish
Started: 05/01/2018
Status: Active
Attachments: No files
Logo Logo
Loading...