Announcement

Collapse
No announcement yet.

Unexpected Point Break study results & how do I insert an image into my thread?

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

  • Unexpected Point Break study results & how do I insert an image into my thread?

    1] I unsuccessfully tried to insert an image for this question into this thread. Please tell me how to do that.

    2] Below is code for a study which I applied to a daily chart. It displays horizontal green and red colored horizontal rectangles to show "Up" or "Down" mode. However the switch from one color to the other sometimes does not ocur at the correct time [eg] when the close is below the low of the previous 3 days the color does not change from green to red? [Sometimes colors switch correctly and sometimes not.]

    /************************************************** ***************
    Provided By : eSignal (c) Copyright 2004
    Description: Point Break Bars for Bar Chart

    Version: 1.0

    Notes:
    This study displays PB bars on regular bar or candlestick chart.

    Formula Parameters: Defaults:
    Point Break Amount 3
    Price Source Close
    Up Color Light Green
    Dn Color Light Red
    Outline Color Grey
    ************************************************** ***************/

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Point Break Bars");
    setCursorLabelName("PB Open", 0);
    setCursorLabelName("PB High", 1);
    setCursorLabelName("PB Low", 2);
    setCursorLabelName("PB Close", 3);
    setPlotType(PLOTTYPE_SQUAREWAVE, 0);
    setPlotType(PLOTTYPE_SQUAREWAVE, 1);
    setPlotType(PLOTTYPE_SQUAREWAVE, 2);
    setPlotType(PLOTTYPE_SQUAREWAVE, 3);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(2, 1);
    setDefaultBarThickness(2, 2);
    setDefaultBarThickness(2, 3);
    setDefaultBarFgColor(Color.RGB(95,95,95), 0);
    setDefaultBarFgColor(Color.RGB(95,95,95), 1);
    setDefaultBarFgColor(Color.RGB(95,95,95), 2);
    setDefaultBarFgColor(Color.RGB(95,95,95), 3);
    setShowTitleParameters(false);

    var fp1 = new FunctionParameter("nPB", FunctionParameter.NUMBER);
    fp1.setName("Point Break Amount");
    fp1.setLowerLimit(2);
    fp1.setDefault(3);
    var fp2 = new FunctionParameter("sSource", FunctionParameter.STRING);
    fp2.setName("Price Source");
    fp2.addOption("Open");
    fp2.addOption("High");
    fp2.addOption("Low");
    fp2.addOption("Close");
    fp2.addOption("HL/2");
    fp2.addOption("HLC/3");
    fp2.addOption("OHLC/4");
    fp2.setDefault("Close");
    var fp3 = new FunctionParameter("cUp", FunctionParameter.COLOR);
    fp3.setName("Up Color");
    fp3.setDefault(Color.RGB(140, 220, 140));
    var fp4 = new FunctionParameter("cDn", FunctionParameter.COLOR);
    fp4.setName("Down Color");
    fp4.setDefault(Color.RGB(220, 140, 140));
    var fp5 = new FunctionParameter("cOutline", FunctionParameter.COLOR);
    fp5.setName("Outline Color");
    fp5.setDefault(Color.RGB(95,95,95));
    }

    var aPBopen = null;
    var aPBhigh = null;
    var aPBlow = null;
    var aPBclose = null;
    var bInit = false;
    var vPBtrend = "Up"; // Up or Dn - Developing PB bar
    var vPBtrend1 = "Up"; // Up or Dn - Confirmed PB bar
    var bNew = false; // New PB bar
    var Price = null;
    var Price1 = null;


    function main(nPB, sSource, cUp, cDn, cOutline) {
    var nState = getBarState();

    if (nState == BARSTATE_NEWBAR) {
    Price1 = Price;
    vPBtrend1 = vPBtrend;
    if (bNew == true) {
    // New PB bar confirmed, update PB arrays
    var vH = aPBhigh[0];
    var vL = aPBlow[0];
    if (vPBtrend == "Up") {
    aPBopen.pop();
    aPBopen.unshift(vH);
    aPBhigh.pop();
    aPBhigh.unshift(Price);
    aPBlow.pop();
    aPBlow.unshift(vH);
    aPBclose.pop();
    aPBclose.unshift(Price);
    } else if (vPBtrend == "Dn") {
    aPBopen.pop();
    aPBopen.unshift(vL);
    aPBhigh.pop();
    aPBhigh.unshift(vL);
    aPBlow.pop();
    aPBlow.unshift(Price);
    aPBclose.pop();
    aPBclose.unshift(Price);
    }
    }
    }

    Price = null;
    switch (sSource) {
    case "Open" :
    Price = open(0);
    break;
    case "High" :
    Price = high(0);
    break;
    case "Low" :
    Price = low(0);
    break;
    case "Close" :
    Price = close(0);
    break;
    case "HL/2" :
    Price = (high(0) + low(0) )/ 2;
    break;
    case "HLC/3" :
    Price = (high(0) + low(0) + close(0) )/ 3;
    break;
    case "OHLC/4" :
    Price = (open(0) + high(0) + low(0) + close(0) )/ 4;
    break;
    }

    if (bInit == false) {
    setStudyTitle(nPB + " Point Break Bars (Price Source: " + sSource + ")");
    setDefaultBarFgColor(cOutline, 0);
    setDefaultBarFgColor(cOutline, 1);
    setDefaultBarFgColor(cOutline, 2);
    setDefaultBarFgColor(cOutline, 3);
    aPBopen = new Array(nPB);
    aPBhigh = new Array(nPB);
    aPBlow = new Array(nPB);
    aPBclose = new Array(nPB);
    for (var i = 0; i < nPB; i++) {
    aPBopen[i] = Price;
    aPBhigh[i] = Price;
    aPBlow[i] = Price;
    aPBclose[i] = Price;
    }
    bInit = true;
    }

    // Test for new PB bar
    if (Price1 == null) return;
    bNew = false;
    vPBtrend = vPBtrend1;
    var nPBmax = aPBhigh[0];
    var nPBmin = aPBlow[0];
    for (var i = 0; i < nPB; i++) {
    nPBmax = Math.max(nPBmax, aPBhigh[i]);
    nPBmin = Math.min(nPBmin, aPBlow[i]);
    }
    if (vPBtrend == "Up") {
    if (Price > nPBmax) {
    bNew = true;
    } else if (Price < nPBmin) {
    bNew = true;
    vPBtrend = "Dn";
    }
    } else if (vPBtrend == "Dn") {
    if (Price > nPBmax) {
    bNew = true;
    vPBtrend = "Up";
    } else if (Price < nPBmin) {
    bNew = true;
    }
    }

    // Current or developing PB bar
    var nPBo = aPBopen[0];
    var nPBh = aPBhigh[0];
    var nPBl = aPBlow[0];
    var nPBc = aPBclose[0];
    if (bNew == true) { // New unconfirmed PB bar
    var vH = aPBhigh[0];
    var vL = aPBlow[0];
    if (vPBtrend == "Up") {
    nPBo = vH;
    nPBh = Price;
    nPBl = vH;
    nPBc = Price;
    } else if (vPBtrend == "Dn") {
    nPBo = vL;
    nPBh = vL;
    nPBl = Price;
    nPBc = Price;
    }
    }

    // PB Bar Coloring
    var PBColor = cDn;
    if (vPBtrend == "Up") PBColor = cUp;
    for (var i = 0; i < 4; i++) {
    setBarBgColor(PBColor, i, nPBl, nPBh);
    }

    return new Array(nPBo, nPBh, nPBl, nPBc);
    }

  • #2
    jcm21
    See the reply to the same question you asked in this thread
    Alex


    Originally posted by jcm21
    1] I unsuccessfully tried to insert an image for this question into this thread. Please tell me how to do that.

    Comment


    • #3
      Thanks Alex.

      I remembered the first part of your answer [ie]
      "The easiest way to include an image in a post is to attach it as a file using the Attach File option that is available when you compose the message. You are limited to one attachment per post."

      However I forgot the 2nd part [ie]
      "You can also include inline images where the image is stored on the web and you include its URL address inside the [ IMG ] [ /IMG ] tags (without any spaces) in the body of your message. In this case you can have multiple images in a post"

      Pursuing it further, can I use the [ IMG ] [ /IMG ] tags approach and insert [copy/paste] between the tags an image from an image capture program I have [Snapshot]?

      Also what are the mechanics of placing the [ IMG ] [ /IMG ] tags
      into my message - I unsuccessfully tried several things.

      Comment


      • #4
        jcm21
        See the reply at the same link I indicated in my previous post
        If you have further questions regarding this topic please post them in that thread (or forum)
        Alex


        Originally posted by jcm21
        Thanks Alex.

        I remembered the first part of your answer [ie]
        "The easiest way to include an image in a post is to attach it as a file using the Attach File option that is available when you compose the message. You are limited to one attachment per post."

        However I forgot the 2nd part [ie]
        "You can also include inline images where the image is stored on the web and you include its URL address inside the [ IMG ] [ /IMG ] tags (without any spaces) in the body of your message. In this case you can have multiple images in a post"

        Pursuing it further, can I use the [ IMG ] [ /IMG ] tags approach and insert [copy/paste] between the tags an image from an image capture program I have [Snapshot]?

        Also what are the mechanics of placing the [ IMG ] [ /IMG ] tags
        into my message - I unsuccessfully tried several things.

        Comment


        • #5
          Rather than trying to insert an image I have attached a bitmap image.

          Note that the close of the 5th bar from the left [the left most bar is the oldest bar on the chart] is lower than the lows of the previous 3 bars so therefore should not the green rectangle have changed color to red? Likewise the close of the 11th bar from the left is higher than the highs of the previous 3 bars so therefore should not the red rectangle have changed color to green?

          The code for the study is displayed in my original new thread.
          Attached Files

          Comment


          • #6
            jcm21
            Without seeing at least the previous 3 colored blocks or [in order to replicate the same condition] knowing what symbol and interval you are plotting, the Time Template settings and the date and time at which this occurred it is not possible to determine based on your image where there should have been a reversal.
            Having said that (and assuming you are using the formula with the default settings) then a reversal will occur only when the Close of a bar is higher or lower than the previous 3 blocks and not of the previous 3 bars. If there are no 3 blocks then a bar must close above or below the High or the Low of the prior block. Enclosed below are a couple of examples with comments.
            Note that this formula was created to replicate a 3PB/3LB chart type on a regular bar/candlestick chart. For more information on the 3PB/3LB chart type you may want to review this article in the eSignal KnowledgeBase.
            Alex







            Originally posted by jcm21
            Rather than trying to insert an image I have attached a bitmap image.

            Note that the close of the 5th bar from the left [the left most bar is the oldest bar on the chart] is lower than the lows of the previous 3 bars so therefore should not the green rectangle have changed color to red? Likewise the close of the 11th bar from the left is higher than the highs of the previous 3 bars so therefore should not the red rectangle have changed color to green?

            The code for the study is displayed in my original new thread.

            Comment


            • #7
              Thanks Alex

              Hello Alex,

              That was really helpful. The study works exactly as advertised. Because my error was thinking in terms of bars rather than blocks, the attached snapshot I sent did not show 3 previous blocks - because I did not think it was relevant.

              Thanks again,
              Joe Miller
              Last edited by jcm21; 11-28-2007, 05:35 AM.

              Comment


              • #8
                Joe
                You are most welcome
                Alex



                Originally posted by jcm21
                Hello Alex,

                That was really helpful. The study works exactly as advertised. Because my error was thinking in terms of bars rather than blocks, the attached snapshot I sent did not show 3 previous blocks - because I did not think it was relevant.

                Thanks again,
                Joe Miller

                Comment

                Working...
                X