Announcement

Collapse
No announcement yet.

Help With Heikin Inside Bars, Please

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

  • Help With Heikin Inside Bars, Please

    Hello,
    I'm trying to paint a separate color for inside bars in the the attached study, but I'm not having any luck. Can you help, please? Thank you.
    Diane
    Attached Files

  • #2
    Diane
    The reason the script is not working is because in the conditional statement in line 152 you are using an invalid syntax.
    haHigh and haLow are not a price series hence you cannot retrieve their values using the notation haHigh(1) and haLow(1). As an aside even if they were a price series the value being called would be incorrect as it would reference the following bar and not the previous one which would instead require a negative bar index ie -1.
    Because haHigh and haLow are not a series you will need to create their historical values using the same logic that I suggested to you in this thread (you can find another example in this thread)
    As a first step you need to declare the required global variables (called for example haHigh1 and haLow1) which will be used to store the prior bar's values of haHigh and haLow. At the same time you will also need to declare haHigh and haLow as global variables since they are currently declared as local variables (this entails removing the var in lines 140 and 141)
    PHP Code:
    var haHigh 0;
    var 
    haLow 0;
    var 
    haHigh1 0;
    var 
    haLow1 0;
     
    function 
    main(...){ 
    When you have done that you need to add at the beginning of main the logic that will transfer the last computed values of haHigh and haLow to haHigh1 and haLow[q[/i] eg
    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){
        
    haHigh1 haHigh;
        
    haLow1 haLow;

    By the way note that a similar logic is also used in lines 120 and 121 to create the prior bar's values of haClose and haOpen
    Once you have those values then you can use them in your condition that defines the inside bar and applies the desired color
    Alex

    Comment


    • #3
      Hi Alex,
      Thank you again for your most valuable help. You are indeed THE Super Moderator!
      Diane

      Comment


      • #4
        Diane
        You are most welcome and thank you for the compliment
        Alex

        Comment

        Working...
        X