Announcement

Collapse
No announcement yet.

MA displayed as flatlines

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

  • MA displayed as flatlines

    Hello

    attached is a simple 9 wma. Under the "formula configuration" tab I have sent the 9 wma to display as a flatline. It works fine.

    Question ...

    1. Is there a way to lengthen the length of the line to a length that I desire? ex= say the line length is 1/4 inch, can I make it 1/2 inch or some other parameter?

    2. Is there a way to limit the amount of flatlines that are shown? Like say the last 4 flatlines etc?

    Thanks

    Pogman
    Attached Files

  • #2
    Pogman
    It is possible however you will need to use the Editor as it cannot be done with the Formula Wizard.
    You will need to draw the returned values using the drawLineRelative() function instead of returning (ie plotting) those values to the chart
    Declare a global variable [ie outside of main() or preMain()] called Counter and set it initially to a value of 0 eg
    PHP Code:
    var Counter 0
    Then in the main() function add the following lines of code (see the comments)
    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){//at every new bar
        
    Counter++;//increase the counter by 1
        
    if(Counter==4){//if Counter is equal to 4 (to plot just the last four bars)
         
    Counter=0;//reset Counter to 0
        
    }
    }
    //the next line of code is used to draw the last 4 values of the WMA
    drawLineRelative(-2vWMA9.getValue(MAStudy.MA), 0vWMA9.getValue(MAStudy.MA), PS_SOLID2Color.red"line"+Counter); 
    Then remove vWMA9.getValue(MAStudy.MA) from the return statement and save the efs with a different name.
    When you run the efs it should draw 4 lines (with a width of three bars going back) in correspondence of the last 4 values of the WMA
    Alex

    Comment


    • #3
      HI Alex

      As usual your are phenomenal. Worked perfectly.
      for those interested it is attached below.

      Have a great Night.

      Pogman
      Attached Files

      Comment


      • #4
        Pogman
        As usual you are most welcome and thank you for the kind words.
        Alex

        Comment

        Working...
        X