Announcement

Collapse
No announcement yet.

Tell me why the Diamonds plot in the wrong place

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

  • Tell me why the Diamonds plot in the wrong place

    I have some test code that puts the plotted diamonds in the wrong place. They show up where they should not be and not where they should be. There should be a diamond for every green bar. The red line is put up by the same block of code and is in the correct place but there is no diamond there. I think it only shows the final red line. (this was done just as the market closed)

    The code is here (image below):

    //test bar color deal
    if (DIOscState == DIOscIN) {
    setBarBgColor (Color.lime,0,35,40);
    }
    if (DIOscState == DIOscBET) {
    setBarBgColor (Color.yellow,0,30,35);
    }
    if (DIOscState == DIOscOUT) {
    setBarBgColor (Color.lightgrey,0,25,30);
    }
    // Build array (FILO buffer) of DIOscStateHist values of length HistLength. Update on change only.
    if (DIOscState != LastState) {
    if (DIOscStateHist.unshift(DIOscState) > HistLength) {
    DIOscHist.pop();
    }
    //Simple Test Alerts
    if (DIOscState == DIOscIN) {
    drawShapeRelative(curBar, vADX.getValue(curBar),Shape.DIAMOND,null,Color.red ,Shape.BOTTOM, ++ShapeCnt);
    addLineTool(LineTool.VERT,curBar,2,Color.red,"test line");
    Alert.addToList (Symbol,"DI Cross" + " " + curSymbol + " " + curInterval, Color.black, Color.lime);
    debugPrintln ("AlertDI barCount: "+barCount+" "+curSymbol+" "+curInterval);
    if (DoSound == true) Alert.playSound("SoundWav");
    }
    LastState = DIOscState;
    }
    Attached Files
    Last edited by jgr; 07-27-2009, 01:30 PM.

  • #2
    Well after an hour of fiddling around I figured this out.

    (It would be nice if the descriptioins in the KB were sufficently complete that this kind of testing would not be required to understand how a function works.)

    To get the Shapes and line to both draw on the correct bar (no streaming data) it must have 0 for the current bar in the drawShapeRelative, but the value from getCurrentBarIndex() for the bar in the addLineTool

    drawShapeRelative(0, vADX.getValue(0),Shape.DIAMOND,null,Color.red,Shap e.BOTTOM, ++ShapeCnt);

    addLineTool(LineTool.VERT,curBar,2,Color.red,++Sha peCnt);

    Also DrawShape() can be used instead of DrawShapeRelative().

    Comment

    Working...
    X