Announcement

Collapse
No announcement yet.

Delayed Line off set

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delayed Line off set

    I do offset of Delayed Line and want to display it in 26 ahead.
    How can you do it?

    /************************************************** ***************
    Provided By : eSignal. (c) Copyright 2004
    ************************************************** ***************/

    var vTurn = new DonchianStudy(9, 0);
    var vStandard = new DonchianStudy(26, 0);
    var vLead1a = new DonchianStudy(26, 26);
    var vLead1b = new DonchianStudy(9, 26);
    var vLead2 = new DonchianStudy(52, 26);


    var vCntr = 0;
    var vICntr = 0;

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Ichimoku");
    setCursorLabelName("Turning Line", 0);
    setCursorLabelName("Standard Line", 1);
    setCursorLabelName("Delayed Line", 2);
    setCursorLabelName("Leading Span 1", 3);
    setCursorLabelName("Leading Span 2", 4);
    setDefaultBarFgColor(Color.RGB(255, 102, 255), 0);
    setDefaultBarFgColor(Color.RGB(255, 0, 0), 1);
    setDefaultBarFgColor(Color.RGB(0, 0, 255), 2);
    setDefaultBarFgColor(Color.RGB(204, 204, 204), 3);
    setDefaultBarFgColor(Color.RGB(0, 153, 0), 4);
    setShowTitleParameters(false);
    setDefaultBarThickness(1,2)

    var fp1 = new FunctionParameter("sCloud", FunctionParameter.STRING);
    fp1.setName("Ichimoku Cloud Style");
    fp1.addOption("Striped");
    fp1.addOption("Solid");
    fp1.setDefault("Striped");

    var fp2 = new FunctionParameter("cCloud", FunctionParameter.COLOR);
    fp2.setName("Ichimoku Cloud Color");
    fp2.setDefault(Color.RGB(102, 255, 102));
    }

    function main(sCloud, cCloud) {

    if(getBarState() == BARSTATE_NEWBAR){
    vCntr +=1;
    vICntr +=1;
    if (vICntr > 350) vICntr = 0;
    }

    if(vCntr<53) return;

    var nTurningLine = vTurn.getValue(DonchianStudy.BASIS);
    var nStandardLine = vStandard.getValue(DonchianStudy.BASIS);
    var nLeadingSpan1 = (vLead1a.getValue(DonchianStudy.BASIS) + vLead1b.getValue(DonchianStudy.BASIS)) / 2;
    var nLeadingSpan2 = vLead2.getValue(DonchianStudy.BASIS);
    if (nTurningLine == null || nStandardLine == null ||
    nLeadingSpan1 == null || nLeadingSpan2 == null) return;

    if (sCloud == "Striped") {
    drawLineRelative(0, nLeadingSpan1, 0, nLeadingSpan2, PS_SOLID, 1, cCloud, "Cloud"+vICntr);
    } else {
    if(nLeadingSpan1>nLeadingSpan2)
    setBarBgColor(Color.RGB(102,255,102), 0, nLeadingSpan2, nLeadingSpan1);
    if(nLeadingSpan1<nLeadingSpan2)
    setBarBgColor(Color.RGB(204,204,204), 0, nLeadingSpan1, nLeadingSpan2);
    }

    if(getBarState() == BARSTATE_NEWBAR){
    var nNum = 1;
    }else{
    var nNum = 0;
    }

    if(getBuildNumber()>636){
    setBar(Bar.Value,-26+nNum,2,close(0));
    }else{
    setBar(Bar.Value,-26+nNum,new Array(null,null,close(0),null,null));
    }

    return new Array(nTurningLine, nStandardLine, null, nLeadingSpan1, nLeadingSpan2);
    }
    Attached Files

  • #2
    kounosuke
    To offset the Delayed Line forward by 26 bars instead of backwards do the following
    Remove (or comment out) the following section of code from your script
    PHP Code:
     if(getBuildNumber()>636){
            
    setBar(Bar.Value,-26+nNum,2,close(0));
        }else{
            
    setBar(Bar.Value,-26+nNum,new Array(null,null,close(0),null,null));
        } 
    Then replace the return statement with the following
    PHP Code:
    return new Array(nTurningLinenStandardLineclose(-26), nLeadingSpan1nLeadingSpan2); 
    Once you implement these changes the Delayed Line will be offset 26 bars forward
    Alex

    Comment


    • #3
      HI,Alexis

      I did problem solving. Thank you.

      Comment


      • #4
        kounosuke
        You are most welcome
        Alex

        Comment

        Working...
        X