Announcement

Collapse
No announcement yet.

Shifting indicator forward

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shifting indicator forward

    I have developed a custom indicator. I have the calculations correct but I would like to shift the entire study forward by one period into the future so it displays to the right of the chart.

    Is there an easy way to do this?
    Antonios Hadjigeorgalis
    Baltimore, MD

  • #2
    Hello Antonios,

    You can use the drawLineRelative() function to draw the line segment for the future bar.

    To shift the study forward by one bar you could create a global variable to store the value of the study to be returned on the next bar. Here's a basic example of what you'll need to do.

    PHP Code:
    var myValue null;
    var 
    myValue1 null;

    function 
    main() {
        if (
    getBarState() == BARSTATE_NEWBAR && myValue != null) {
            
    myValue1 myValue;     //trasfer previous bar's value to myValue1
        
    }
        
        
    // calculate new myValue
        
    myValue // custom calc
        
        
    if (getCurrentBarIndex() == && myValue1 != null) {
            
    drawLineRelative(0myValue1myValue1PS_SOLID1Color.blue"future bar");
        }
        
        if (
    myValue1 != null) {
            return 
    myValue1;
        } else {
            return;
        }

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X