Announcement

Collapse
No announcement yet.

Every other bar ?

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

  • Every other bar ?

    I have been building a script all day, and struggling with the results. I decided to start with the less than current bars and get them to work, and then move into the real time bars. I kept working and debugging, and working and debugging and what I found is that on the historical bars, only every other one is being considered in my formula - which of course, screws up my results... Anybody ever seen this before ? Any solutions ?

    1) I am running an NQ H4, 233T chart
    2) I am assuming that historical bar passes through the main section of my efs
    3) Here's a scaled down version of my efs:

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Every Other Bar");
    setShowCursorLabel(false);
    }

    var iChartBarCount=0;
    var iBarIndex;
    var iLabel=0;

    function main() {

    iBarIndex=getCurrentBarIndex();

    iChartBarCount++;

    drawTextRelative(iBarIndex, low(iBarIndex)-.25, iChartBarCount, Color.white, null,
    Text.ONTOP|Text.CENTER, "Courier", 6, "Label"+iChartBarCount,
    null, null);
    drawShapeRelative(iBarIndex, high(iBarIndex)+.5, Shape.DOWNTRIANGLE, null, Color.yellow,
    Shape.ONTOP|Shape.BOTTOM,"Label"+iLabel);
    iLabel++;

    }
    ===

    And, if anyone is wondering, I just did the same thing on a 5 minute bar...So, is there any help/hope ?

    Thanks -
    Jennifer

  • #2
    Hi Jennifer,

    The problem you're having has to do with how you are using the tag name parameter. Because you were using the same tag names for both the text and shapes drawn on your chart, some were getting redrawn esentially. Anyway, the fix is to use a unique tag name for both sets. In the code below you'll notice that I changed the tag names to "TextLabel"+iChartBarCount and "ShapeLabel"+iChartBarCount. You can also use the same counter in this instance as well.

    jenniferBars.efs

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Every Other Bar");
        
    setShowCursorLabel(false);
    }

    var 
    iChartBarCount=0;
    var 
    iBarIndex;

    function 
    main() {

        
    iBarIndex getCurrentBarIndex();

        
    iChartBarCount++;

        
    drawTextRelative(0low()-.25iChartBarCountColor.whitenull
            
    Text.ONTOP|Text.CENTER"Courier"6"TextLabel"+iChartBarCount);
        
    drawShapeRelative(0high()+.5Shape.DOWNTRIANGLEnullColor.yellow
            
    Shape.ONTOP|Shape.BOTTOM,"ShapeLabel"+iChartBarCount);


    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks, that straightens me out...
      I really appreciate the help !
      Jennifer

      Comment

      Working...
      X