Announcement

Collapse
No announcement yet.

color prior closing bar

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

  • color prior closing bar

    I would like to use Alex's Keltner code (see attached) and color the prior closing bar that closes above or below the associated close of the upper or lower keltner band. EX: The prior closing bar closes below the low of the prior associated keltner band then that prior closing bar is red. I have tried and some bars are coloring red but actually closing above the low keltner band. I am not sure how to properly reference the prior low close of the prior keltner band.

    thank you to anyone who can help. A novice and I feel like I am trying to learn brain surgery.

    Rick
    Attached Files

  • #2
    Re: color prior closing bar

    Rick
    At this time efs cannot color historical price bars. It can only color the one currently being processed.
    The reason why some bars are colored in red even if the Close of that bar is above the lower Keltner band is because in your conditional statement ie
    if(close(-1) < vLower)
    you are checking if the prior Close is below the current Keltner and not the prior bar's Keltner.
    Having said that is there any reason why you would not evaluate if the current Close is above/below the corresponding Keltner band and color the bar consequently? For example
    PHP Code:
    if(close(0) > vUpper) {
        
    setPriceBarColor(Color.lime); 
        
    //other commands to execute
    }
    if(
    close(0) < vLower) {
        
    setPriceBarColor(Color.red);
        
    //other commands to execute

    In this case if the Close is neither below the lower Keltner band nor above the upper Keltner band the price bar will be colored in the default color you have set in preMain
    As an aside notice that I have enclosed the commands to execute [when either condition is true] in curly brackets. You need to do that whenver you want to execute multiple commands based on a condition. You can skip the curly brackets only if you are executing a single command
    Alex


    Originally posted by rrolwes1
    I would like to use Alex's Keltner code (see attached) and color the prior closing bar that closes above or below the associated close of the upper or lower keltner band. EX: The prior closing bar closes below the low of the prior associated keltner band then that prior closing bar is red. I have tried and some bars are coloring red but actually closing above the low keltner band. I am not sure how to properly reference the prior low close of the prior keltner band.

    thank you to anyone who can help. A novice and I feel like I am trying to learn brain surgery.

    Rick

    Comment


    • #3
      Alex

      Once again thank you for the rapid response and especially the clear and concise answer. I actually understood it.

      rick

      Comment


      • #4
        Rick
        You are most welcome
        Alex


        Originally posted by rrolwes1
        Alex

        Once again thank you for the rapid response and especially the clear and concise answer. I actually understood it.

        rick

        Comment

        Working...
        X