Announcement

Collapse
No announcement yet.

60 min bar interval not calculating correctly for EFS script

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

  • 60 min bar interval not calculating correctly for EFS script

    I'm currently trying to calculate the difference between the current price and the open price of any intraday interval. A value is returned, and its color is set to green or red depending on whether this value is positive or negative. I then use this in a watchlist. My code works for every bar interval EXCEPT for the 60 minute interval. I can't figure out why although I think it has something to do with eSignal using the top of the hour vs. the bottom of the hour in it's calculation. With respect to the 60 min interval I want to see the period from 9:30 am - 10:30 am, 10:30 am to 11:30 am, etc...A chart will display this correctly but for some reason I cannot get EFS code to correctly calculate it. If anyone has insight on this issue or can help me code for this I would really appreciate it. Thanks.

    Here's my code:

    function preMain() {
    setCursorLabelName('UoD');
    setDefaultBarFgColor(Color.lightgrey);
    }

    function main() {
    var c = Color.black;
    var diff = close(0) - open(0);

    if (diff > 0) {
    c = Color.green;
    } else if (diff < 0) {
    c = Color.red;
    }

    setBarFgColor(c);
    return diff;

    Don
Working...
X