Announcement

Collapse
No announcement yet.

Volume related question

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

  • Volume related question

    I am trying to color the volume bars based on certain criteria

    If Volume (0) is 75% or greater than volume (-1) then color the bar blue,
    however if Volume(-1) is 300% greater than Volume(-2) then ignore Volume(-1) and compare Volume (0) with volume(-2) for the 75% condition.

    I hope I am able to articulate correctly, but basically I want to take a decision to go long or short if there is sufficient volume as compared to the previous bar, however, if the previous bar had seen a significant surge in volume, then I would disregard the previous bar and compare my current bar with the previous to previous bar. (-2).

    Any help will be appreciated
    Thanks

  • #2
    Originally posted by SNR2012 View Post
    I am trying to color the volume bars based on certain criteria

    If Volume (0) is 75% or greater than volume (-1) then color the bar blue,
    however if Volume(-1) is 300% greater than Volume(-2) then ignore Volume(-1) and compare Volume (0) with volume(-2) for the 75% condition.

    I hope I am able to articulate correctly, but basically I want to take a decision to go long or short if there is sufficient volume as compared to the previous bar, however, if the previous bar had seen a significant surge in volume, then I would disregard the previous bar and compare my current bar with the previous to previous bar. (-2).

    Any help will be appreciated
    Thanks
    Not exactly what you ased for but here is a starting point. This script is designed to color bars do some criteria. Perhaps you can substitute your own criteria. You would use a non price study because you are coloring volume bars: setPriceStudy(false).

    /************************************************** **************************************************
    This is a modified eSignal script to make the color of the price bars be the same as seen on the
    W.J. O'Neil Daily Graphs site. Blue bars are drawn when the current price is greater than the close
    of the previous bar close. Red bars are drawn if the current price is below the previous bar's closing
    price. Script modified by Mike Scott
    ************************************************** ************************************************** */
    function preMain() {
    setPriceStudy(true);
    setStudyTitle("O'Neil");
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.blue);
    }

    function main() {

    var vC = close();
    var vPC = close(-1);

    if(vC == null || vPC == null)
    return;

    if(vC > vPC) {
    setPriceBarColor(Color.blue);
    } else if(vC < vPC) {
    setPriceBarColor(Color.red);
    }
    return;
    }
    ....Mike

    Comment


    • #3
      Mike,
      I was travelling and just got back on the forum.Thanks for your feedback and suggested code. Much appreciated.

      As a follow up, how do you identify a bar by the 'time' it closed. I trade on the one hour bar and I want to be able to check a condition on the 3.00 pm bar close. I understand we can refer to bars by index like (0),(-1),(-2) and so on, but how do you refer to a specific bar based on the closing time of that bar?

      Comment

      Working...
      X