Announcement

Collapse
No announcement yet.

Would like help with a formula

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

  • Would like help with a formula

    Hi

    I'm trying to write a formular that posts a number over each bar that closes lower than the previous bar but one. I basically want to be able to quickly count the number of bars that have trended lower that the bar one before last....and I want this to continue as long as the condition exists.

    I'm having trouble working out how to instruct the wizard to run this.

    Can anyone point me in the right direction.

    Thanks

    aj1
    aj1

  • #2
    aj1
    You will not be able to do what you are trying to accomplish using only the Formula Wizard. This is because you need to have some type of counter which needs to be a global variable (ie declared outside of function main()) which the Formula Wizard cannot do.
    The efs you want is relatively simple to create. First declare a variable (called for example vCounter) outside of function main() and set it to an initial value of 0.
    Then in function main enclose in a BARSTATE_NEWBAR the condition you want such as for example if(low(-1) < low(-3)) and have it increase the counter by 1 every time the condition returns true. Add an else to zero the counter again when the condition is no longer true.
    Once you have done that you can use the drawTextRelative() to write the numbers tallied by the counter.
    Give it a try and if you encounter any problems post what you have done and someone may be available to help
    Alex

    Comment

    Working...
    X