Announcement

Collapse
No announcement yet.

Crossovers and Objects

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

  • Crossovers and Objects

    During the current bar the stochastic K/D values can cross, uncross, or re-cross. What code is required to get an object to display this changing condition during the current bar? No problem with background color changing intrabar, but objects don't seem to behave the same way; once objects appear, they don't change.

    In the formula, the idea is to have an object reflect the changing condition of the K/D cross. For example, for an unclosed bar, light green or light red on a cross, and nothing when it uncrosses.

    If the bar closes in a crossover condition, then the light green or light red object color changes to dark green or dark red.

    I've tried it a few ways, and no problem with background color, but it's not working for objects. Thanks for any ideas.

    Here's some test code:

    //vFastLast and vSlowLast is for bar -1
    //vFast2 and vSlow2 is for bar -2

    var vLastAlert = -1;

    //K crossing D to downside on current bar (bar not closed yet)
    if ((vFastLast >= vSlowLast) && (vFast < vSlow)) {
    drawShapeRelative(0, 5, Shape.SQUARE, "", Color.RGB(254,213,195), Shape.RELATIVETOTOP | Shape.ONTOP);
    vLastAlert = 1; //to update every tick
    }

    //last bar closed with K crossed below D
    if ((vFast2 >= vSlow2) && (vFastLast < vSlowLast)) {
    drawShapeRelative(-1, 5, Shape.SQUARE, "", Color.RGB(255,0,0), Shape.RELATIVETOTOP | Shape.ONTOP);
    }

    //K crossing D to upside on current bar (bar not closed yet)
    if ((vFastLast <= vSlowLast) && (vFast > vSlow)) {
    drawShapeRelative(0, 0, Shape.SQUARE, "", Color.RGB(157,252,141), Shape.RELATIVETOBOTTOM | Shape.ONTOP);
    vLastAlert = 2; //to update every tick
    }

    //last bar closed with K crossed above D
    if ((vFast2 <= vSlow2) && (vFastLast > vSlowLast)) {
    drawShapeRelative(-1, 0, Shape.SQUARE, "", Color.RGB(0,128,0), Shape.RELATIVETOBOTTOM | Shape.ONTOP);
    }

  • #2
    Lancer
    Try the attached efs. It will draw a yellow or lime "temporary" arrow which will appear/disappear on intrabar crosses and if at the close of the bar the cross is confirmed it will draw a red or green arrow in place of the temporary one
    Alex
    Attached Files

    Comment


    • #3
      Hey now that's exactly right. Thank you Alexis. <now to study why that works>

      Comment

      Working...
      X