Indicator not working

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #21047 quote
    vsoler
    Participant
    Junior

    Hello,

    The following indicator does not return any values.

    I want to build an indicator called “a” where each value is the one from the previous bar to which I add the price variation for the day multiplied (weighted) by the volume variation of the day.

    1. Why it does not work?
    2. How should the problem be fixed?

    Thank you in advance

     

    once a=close
    
    v=volume
    rv=v/v[1]
    
    p=close
    dp=p-p[1]
    
    a=a[1]+dp*rv
    
    return a
    #21092 quote
    Nicolas
    Keymaster
    Master

    Did you test your indicator on instrument that have Volumes?

    #21101 quote
    vsoler
    Participant
    Junior

    Yes Nicolas,

    I attach a chart on Pepsico. My indicator is in the bottom window

    #21107 quote
    Nicolas
    Keymaster
    Master

    It should work with this modified code, like you did for the ‘a’ variable, giving only once the volume value to the ‘v’ one, fixed it. Because v[1] is not defined the first time the code is read, the calculation can’t complete itself and that’s why you didn’t get anything.

    once a=close
    once v=volume
    
    if barindex>2 then 
    v=volume
    rv=v/v[1]
    
    p=close
    dp=p-p[1]
    
    a=a[1]+dp*rv
    endif
    
    return a
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Indicator not working


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
vsoler @vsoler Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Nicolas
9 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/14/2017
Status: Active
Attachments: No files
Logo Logo
Loading...