Announcement

Collapse
No announcement yet.

Look ahead indication question

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

  • Look ahead indication question

    I'm writting a look ahead indicator and I want to plot to the right of Bar (0) - the current bar. Is there a way to plot to Bar (-1) ?

    ...bob
    ...bob

  • #2
    bob
    EFS does not plot where there is no data as for example to the right of bar(0) [ie at bar(1) and not bar(-1) which is the bar before bar(0)]
    You can however use draw functions such as drawLineRelative() to replicate the plot. For an example of how to do this see this thread
    Alex

    Comment


    • #3
      bob
      The example provided in the thread I indicated in my prior reply shows how to draw the value of a study displaced forward by 1 period.
      If you need to displace by more than one period then you will need to draw a line for each period that the study is being displaced. While you could do that by writing as many drawLineRelative() commands as necessary a more efficient way to accomplish the task is to use a for loop as shown in the following basic example of a moving average offset forward by 5 periods
      Alex

      PHP Code:
      function preMain(){
          
      setPriceStudy(true);
      }
       
      function 
      main(){
       
          var 
      Avg sma(10);
          var 
      Offset 5;
          var 
      AvgVal Avg.getValue(-Offset);
          
          for (var 
      x=1x<=Offsetx++){
              
      drawLineRelative(x-1,Avg.getValue((x-Offset)-1),x,Avg.getValue(x-Offset),PS_SOLID,1,Color.blue,"plot"+x);
          } 
          
          return 
      AvgVal;

      Comment

      Working...
      X