Announcement

Collapse
No announcement yet.

paint bars

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

  • paint bars

    Hi,

    Not sure if I am missing something or not.
    I want to write a simple efs script.
    The script will draw 2 lines (aa, bb) on the chart that can be user defined. Lets say initially aa = 985 and bb = 989 for the ES (ES U3)
    The script would then color the price bar green is high of the bar is greater than aa. It would color the bar red if the low of the bar is less than bb.
    Seems fairly straightforward. I tried using the wizard for this and ran into problems. I guess the wizard is not set up to allow user defined variables (aa, bb).
    I made some mods to the code in the editor to allow the variables to be user input by adding {aa, bb} to the function main line. I also did a null test for aa and bb and put in some default valies.
    The code compiles correctly and works sometimes. However, I notice at times that some or all of the price bars disappear. This seems to depend on the values of aa and bb.
    If I remove the study the prices bars reappear.

    Any ideas??

    Tx

    kiwi

  • #2
    Forgot to post efs file.
    Attached Files

    Comment


    • #3
      kiwi

      In Line 18 you have the wrong statement for setting the default color of the bars.
      Change that to setDefaultPriceBarColor(Color.black); and it should fix the disappearing bars.
      Those bars disappeared because they did not fit any condition and there was no default color.

      Attached you can find another way of fixing the disappearing bars without using the setDefaultPriceBarColor statement.

      Alex
      Attached Files

      Comment


      • #4
        Thanks Alex.

        Made the change to the EFS using the setDefaultPriceBarColor line.
        Looked at your EFS. I see expression 3, 1 == 1.
        I am not exactly sure what this means.

        kiwi

        Comment


        • #5
          kiwi
          In Set1 you paint the bars if the high is greater than aa, in Set2 you paint them red if the low is less than bb. If you don't have a setDefaultPriceBarColor then when bars are in between aa and bb they don't get painted which is why they would disappear.
          So, if you use a Set3 for a condition 1==1 which is always true by definition then you can paint the bars for all the times in which Set1 and Set2 are not true.
          Alex

          Comment

          Working...
          X