Announcement

Collapse
No announcement yet.

Can't color Price Bars

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

  • Can't color Price Bars

    Once more I'm baffled. This program is trying to do the following:

    Create an average of the Close for the past x bars.

    Create an average of the Open for the past x bars.

    For each bar, if the Closing Avg is <= the Opening Average, color the bar red; if the Closing Avg is > the Opening Average, color the bar lime.

    When I run it with the debug function, it shows that the Closing and Opening Averages are calculated a number of times, then both show null. No bars are colored.

    What have I done now?

    Thanks.
    Attached Files

  • #2
    Richard
    There are several errors in the script.
    The first one is that you have created two function main(...){ in lines 26 and 28. You will need to delete one of them and the corresponding closing bracket in line 60
    The other two errors are in lines 29 and 32 where you are using values [ie close(0) and open(0)] as the source of the sma() functions instead of series [ie. close() and open()]
    In this regard you may want to see the this thread which will provide you with a detailed series of examples of the syntax required by the builtin functions.
    Alex

    Comment


    • #3
      Thank you so much. Once again, you have steered me in the right direction. And despite everything, I am slowly learning.

      My final version is attached.
      Attached Files

      Comment


      • #4
        Richard
        You are most welcome
        Alex

        Comment

        Working...
        X