ขอสูตร td sequential หน่อยครับ

Home Forums CDC Forums General Discussion — The Living Room ขอสูตร td sequential หน่อยครับ

This topic contains 10 replies, has 5 voices, and was last updated by  tadisake 1 month, 4 weeks ago.

  • Author
    Posts
  • #17546

    marvin
    Participant

    เพื่อไว้ดูประกอบแอคชั่นโซนครับ

    ลองเขียนสูตรดู แต่ไม่เป็นผลครับ

  • #17844

    Akee
    Participant

    _SECTION_BEGIN(“TDST_DeMark_Perl”);

    /* Set Parameters. */

    Plotall=ParamToggle(“Plot all lines “, “No|Yes”,1);
    Plotpercent=Param(“Plot percentage above/below visible range “,20,0,100,5,0);
    gapprox=Param(“Proximity Gap Multiplier”,1,0,5,0.5,0);
    bluedist=Param(“Blue_Multiplier”,1.75,0,10,0.25,0);
    reddist=Param(“Red_multiplier”,0.25,0,10,0.25,0);

    /* Initialise variables. */

    sup1=sup2=sup3=sup4=sup5=sup6=sup7=sup8=sup9=Null;
    res1=res2=res3=res4=res5=res6=res7=res8=res9=Null;

    TDSeqBuy=False;
    TDSeqbuydigits=0;
    TDSeqbuyrisk=TDSeqbuyreward=TDSeqbuyrrratio=TDSeqbuystop=0;

    TDSeqSell=False;
    TDSeqselldigits=0;
    TDSeqsellrisk=TDSeqsellreward=TDSeqsellrrratio=TDSeqsellstop=0;

    supinuse=resinuse=Null;
    supvio=resvio=0;
    tfarray=True;
    distance=ATR(10);

    BCDplot=False;
    BSetupind=BCDind=BCDrisk=0;
    BSmaxr=BSminr=BScnt=BSmaxrc=BSminrc=0;
    CurBSmaxr=CurBSminr=CurBScnt=CurBSmaxrc=CurBSminrc=0;
    PreBSmaxr=PreBSminr=PreBScnt=PreBSmaxrc=PreBSminrc=0;
    CurBCDstart=CurBCD=CurBCD8=CurBCDmaxr=CurBCDminr=CurBCDtext=CurBCDfin=0;
    PreBCDstart=PreBCD=PreBCD8=PreBCDmaxr=PreBCDminr=PreBCDtext=PreBCDfin=0;

    SCDplot=False;
    SSetupind=SCDind=SCDrisk=0;
    SSmaxr=SSminr=SScnt=SSmaxrc=SSminrc=0;
    CurSSmaxr=CurSSminr=CurSScnt=CurSSmaxrc=CurSSminrc=0;
    PreSSmaxr=PreSSminr=PreSScnt=PreSSmaxrc=PreSSminrc=0;
    CurSCDstart=CurSCD=CurSCD8=CurSCDmaxr=CurSCDminr=CurSCDtext=CurSCDfin=0;
    PreSCDstart=PreSCD=PreSCD8=PreSCDmaxr=PreSCDminr=PreSCDtext=PreSCDfin=0;

    /* Identify functions and procedures. */

    /* This function checks the TD Sequential Digits for a valid sequence. */

    function seqcheck(TDSeqdigits,ival)
    {
    Loop=0;
    if (TDSeqdigits[ival-1]>0 AND TDSeqdigits[ival-1]<9)
    {
    Loop=TDSeqdigits[ival-1];
    for (jloop=0; jloop<Loop; jloop++)
    {
    TDSeqdigits[ival-1-jloop]=0;
    }
    }
    return TDSeqdigits;
    }

    /* Fuction to set up support and resistance arrays */

    function supres(supresarray,jval,ival,supresValue)
    {
    global tfarray;

    if (IsEmpty(supresarray[jval]))
    {
    tfarray[ival]=False;
    for (jcount=jval; jcount<(ival+1); jcount++)
    {
    supresarray[jcount]=supresvalue;
    }
    }

    return supresarray;
    }

    /* Prodedures to reset TD Sequential Buy arrays. */

    procedure ResetBScur(Loop,Ival)
    {
    for (j=Loop; j<Ival; j++)
    {
    CurBSmaxr[j]=0;
    CurBSminr[j]=0;
    CurBScnt[j]=0;
    CurBSmaxrc[j]=0;
    CurBSminrc[j]=0;

    CurBCDstart[j]=0;
    CurBCD[j]=0;
    CurBCDmaxr[j]=0;
    CurBCDminr[j]=0;
    CurBCD8[j]=0;
    // CurBCDfin[j]=0;
    CurBCDtext[j]=0;
    }
    return;
    }

    procedure ResetBSpre(Loop,Ival)
    {
    for (j=Loop; j<Ival; j++)
    {
    PreBSmaxr[j]=0;
    PreBSminr[j]=0;
    PreBScnt[j]=0;
    PreBSmaxrc[j]=0;
    PreBSminrc[j]=0;

    PreBCDstart[j]=0;
    PreBCD[j]=0;
    PreBCDmaxr[j]=0;
    PreBCDminr[j]=0;
    PreBCD8[j]=0;
    // PreBCDfin[j]=0;
    PreBCDtext[j]=0;
    }
    return;
    }

    /* Procedure to copy the TD Setup Buy arrays (previous) into the TD Setup Buy arrays (current). */

    procedure CopyBSpre(Loop,Ival)
    {
    for (j=Loop; j<Ival; j++)
    {
    CurBSmaxr[j]=PreBSmaxr[j];
    CurBSminr[j]=PreBSminr[j];
    CurBScnt[j]=PreBScnt[j];
    CurBSmaxrc[j]=PreBSmaxrc[j];
    CurBSminrc[j]=PreBSminrc[j];

    CurBCDstart[j]=PreBCDstart[j];
    CurBCD[j]=PreBCD[j];
    CurBCDmaxr[j]=PreBCDmaxr[j];
    CurBCDminr[j]=PreBCDminr[j];
    CurBCD8[j]=PreBCD8[j];
    CurBCDfin[j]=PreBCDfin[j];
    CurBCDtext[j]=PreBCDtext[j];
    }
    return;
    }

    /* Prodedures to reset TD Sequential Sell arrays. */

    procedure ResetSScur(Loop,Ival)
    {
    for (j=Loop; j<Ival; j++)
    {
    CurSSmaxr[j]=0;
    CurSSminr[j]=0;
    CurSScnt[j]=0;
    CurSSmaxrc[j]=0;
    CurSSminrc[j]=0;

    CurSCDstart[j]=0;
    CurSCD[j]=0;
    CurSCDmaxr[j]=0;
    CurSCDminr[j]=0;
    CurSCD8[j]=0;
    // CurSCDfin[j]=0;
    CurSCDtext[j]=0;
    }
    return;
    }

    procedure ResetSSpre(Loop,Ival)
    {
    for (j=Loop; j<Ival; j++)
    {
    PreSSmaxr[j]=0;
    PreSSminr[j]=0;
    PreSScnt[j]=0;
    PreSSmaxrc[j]=0;
    PreSSminrc[j]=0;

    PreSCDstart[j]=0;
    PreSCD[j]=0;
    PreSCDmaxr[j]=0;
    PreSCDminr[j]=0;
    PreSCD8[j]=0;
    // PreSCDfin[j]=0;
    PreSCDtext[j]=0;
    }
    return;
    }

    /* Procedure to copy the TD Setup Sell arrays (previous) into the TD Setup Sell arrays (current). */

    procedure CopySSpre(Loop,Ival)
    {
    for (j=Loop; j<Ival; j++)
    {
    CurSSmaxr[j]=PreSSmaxr[j];
    CurSSminr[j]=PreSSminr[j];
    CurSScnt[j]=PreSScnt[j];
    CurSSmaxrc[j]=PreSSmaxrc[j];
    CurSSminrc[j]=PreSSminrc[j];

    CurSCDstart[j]=PreSCDstart[j];
    CurSCD[j]=PreSCD[j];
    CurSCDmaxr[j]=PreSCDmaxr[j];
    CurSCDminr[j]=PreSCDminr[j];
    CurSCD8[j]=PreSCD8[j];
    CurSCDfin[j]=PreSCDfin[j];
    CurSCDtext[j]=PreSCDtext[j];
    }
    return;
    }

    /* Begin Assignments. */

    SetBarsRequired(sbrAll);

    /* Identify Bullish and Bearish Price Flips. Then, latch these values. */

    Bullflip=IIf(Close>Ref(Close,-4) AND Ref(Close,-1)<Ref(Close,-5),True,False);
    Bearflip=IIf(Close<Ref(Close,-4) AND Ref(Close,-1)>Ref(Close,-5),True,False);

    Bullhold=Flip(Bullflip,Bearflip);
    Bearhold=Flip(Bearflip,Bullflip);

    /* Identify TD Setup’s – Buy and Sell. */

    Buyconsecdays=IIf(Close<Ref(Close,-4),True,False);
    Buy9Bars=BarsSince(BarsSince(Buyconsecdays));
    Buy9Signal=IIf(Buy9Bars==9,True,False);
    Buy9Req=IIf(Buy9Signal==True AND Ref(Bearflip,-8)==True,True,False);

    BSetupind=IIf(Bearhold==True AND Buy9Bars>=9,True,False);
    BSmaxr=IIf(BSetupind==True,HHV(High,Buy9Bars),0);
    BSminr=IIf(BSetupind==True,LLV(Low,Buy9Bars),0);
    BScnt=Sum(BSetupind,BarsSince(BSetupind==False))+8;
    BSmaxrc=IIf(BSetupind==True,HHV(Close,Buy9Bars),0);
    BSminrc=IIf(BSetupind==True,LLV(Close,Buy9Bars),0);

    Sellconsecdays=IIf(Close>Ref(Close,-4),True,False);
    Sell9Bars=BarsSince(BarsSince(Sellconsecdays));
    Sell9Signal=IIf(Sell9Bars==9,True,False);
    Sell9Req=IIf(Sell9Signal==True AND Ref(Bullflip,-8)==True,True,False);

    SSetupind=IIf(Bullhold==True AND Sell9Bars>=9,True,False);
    SSmaxr=IIf(SSetupind==True,HHV(High,Sell9Bars),0);
    SSminr=IIf(SSetupind==True,LLV(Low,Sell9Bars),0);
    SScnt=Sum(SSetupind,BarsSince(SSetupind==False))+8;
    SSmaxrc=IIf(SSetupind==True,HHV(Close,Sell9Bars),0);
    SSminrc=IIf(SSetupind==True,LLV(Close,Sell9Bars),0);

    /* Prepare Countdown Arrays for TD Setup’s – Buy and Sell. */

    Buyconseccloses=IIf(Close<=Ref(Low,-2),True,False);
    Sellconseccloses=IIf(Close>=Ref(High,-2),True,False);

    /* Get the highest high’s and the lowests low’s to have occurred in the last 9 days. */

    HHV9=HHV(High,9);
    LLV9=LLV(Low,9);

    WhenHHV9=HHVBars(High,9);
    WhenLLV9=LLVBars(Low,9);

    /* Begin TD Sequential – Defining the Trend and Identifying Exhaustion Points. */

    for (i=0; i<BarCount; i++)
    {

    /* Obtain TD Sequential Digits to be plotted. */

    if (Buy9Bars>0 AND Buy9Bars<10 AND Bearflip]==True) TDSeqbuydigits=Buy9Bars;
    if (Sell9Bars>0 AND Sell9Bars<10 AND Bullflip]==True) TDSeqselldigits=Sell9Bars;

    /* Delete numbers that were created if there is a break in the sequence before 9 is reached. */

    if (i>0 AND TDSeqbuydigits[i-1]>TDSeqbuydigits) TDSeqbuydigits=seqcheck(TDSeqbuydigits,i);
    if (i>0 AND TDSeqselldigits[i-1]>TDSeqselldigits) TDSeqselldigits=seqcheck(TDSeqselldigits,i);

    /* Update current running support and resistance lines */
    /* How many the program will need is unknown !! – Limit is 9 for each. */

    if (i>0)
    {
    if (sup1[i-1]>-1 AND sup1[i-1]<Close) sup1=sup1[i-1];
    if (sup2[i-1]>-1 AND sup2[i-1]<Close) sup2=sup2[i-1];
    if (sup3[i-1]>-1 AND sup3[i-1]<Close) sup3=sup3[i-1];
    if (sup4[i-1]>-1 AND sup4[i-1]<Close) sup4=sup4[i-1];
    if (sup5[i-1]>-1 AND sup5[i-1]<Close) sup5=sup5[i-1];
    if (sup6[i-1]>-1 AND sup6[i-1]<Close) sup6=sup6[i-1];
    if (sup7[i-1]>-1 AND sup7[i-1]<Close) sup7=sup7[i-1];
    if (sup8[i-1]>-1 AND sup8[i-1]<Close) sup8=sup8[i-1];
    if (sup9[i-1]>-1 AND sup9[i-1]<Close) sup9=sup9[i-1];

    if (res1[i-1]>-1 AND res1[i-1]>Close) res1=res1[i-1];
    if (res2[i-1]>-1 AND res2[i-1]>Close) res2=res2[i-1];
    if (res3[i-1]>-1 AND res3[i-1]>Close) res3=res3[i-1];
    if (res4[i-1]>-1 AND res4[i-1]>Close) res4=res4[i-1];
    if (res5[i-1]>-1 AND res5[i-1]>Close) res5=res5[i-1];
    if (res6[i-1]>-1 AND res6[i-1]>Close) res6=res6[i-1];
    if (res7[i-1]>-1 AND res7[i-1]>Close) res7=res7[i-1];
    if (res8[i-1]>-1 AND res8[i-1]>Close) res8=res8[i-1];
    if (res9[i-1]>-1 AND res9[i-1]>Close) res9=res9[i-1];
    }

    /* The following code is essentially for the drawing of the TDST support and resistance lines. */
    /* Test for a new support level and place in an empty support array */

    if (Sell9Req==True)
    {
    /* Determine which support array to use */

    tfarray=True;
    if (tfarray==True) sup1= supres(sup1,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup2= supres(sup2,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup3= supres(sup3,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup4= supres(sup4,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup5= supres(sup5,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup6= supres(sup6,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup7= supres(sup7,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup8= supres(sup8,(i-WhenLLV9),i,LLV9);
    if (tfarray==True) sup9= supres(sup9,(i-WhenLLV9),i,LLV9);

    /* Check to see if we need to erase the lowest support line (all 9 in-use) to make way for the newest. */

    if (tfarray==True)
    {
    for (j=0; j<BarCount; j++)
    {
    sup1[j]=sup2[j];
    sup2[j]=sup3[j];
    sup3[j]=sup4[j];
    sup4[j]=sup5[j];
    sup5[j]=sup6[j];
    sup6[j]=sup7[j];
    sup7[j]=sup8[j];
    sup8[j]=sup9[j];
    sup9[j]=Null;
    }
    sup9= supres(sup9,(i-WhenLLV9),i,LLV9);
    }

    /* Check to ensure the latest addition is in the correct ‘sup’ array. */

    if ((NOT(IsEmpty(sup9) OR IsEmpty(sup8))) AND sup9<sup8)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup9[j];
    sup9[j]=sup8[j];
    sup8[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup8) OR IsEmpty(sup7))) AND sup8<sup7)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup8[j];
    sup8[j]=sup7[j];
    sup7[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup7) OR IsEmpty(sup6))) AND sup7<sup6)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup7[j];
    sup7[j]=sup6[j];
    sup6[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup6) OR IsEmpty(sup5))) AND sup6<sup5)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup6[j];
    sup6[j]=sup5[j];
    sup5[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup5) OR IsEmpty(sup4))) AND sup5<sup4)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup5[j];
    sup5[j]=sup4[j];
    sup4[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup4) OR IsEmpty(sup3))) AND sup4<sup3)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup4[j];
    sup4[j]=sup3[j];
    sup3[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup3) OR IsEmpty(sup2))) AND sup3<sup2)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup3[j];
    sup3[j]=sup2[j];
    sup2[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(sup2) OR IsEmpty(sup1))) AND sup2<sup1)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=sup2[j];
    sup2[j]=sup1[j];
    sup1[j]=swap[j];
    }
    }
    }

    /* Test for a new resistance level and place in empty resistance array */

    if (Buy9Req==True)
    {

    /* Determine which resistance array to use */

    tfarray=True;
    if (tfarray==True) res1= supres(res1,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res2= supres(res2,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res3= supres(res3,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res4= supres(res4,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res5= supres(res5,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res6= supres(res6,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res7= supres(res7,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res8= supres(res8,(i-WhenHHV9),i,HHV9);
    if (tfarray==True) res9= supres(res9,(i-WhenHHV9),i,HHV9);

    /* Check to see if we need to erase the highest resistance line (all 9 in-use) to make way for the newest. */

    if (tfarray==True)
    {
    for (j=0; j<BarCount; j++)
    {
    res1[j]=res2[j];
    res2[j]=res3[j];
    res3[j]=res4[j];
    res4[j]=res5[j];
    res5[j]=res6[j];
    res6[j]=res7[j];
    res7[j]=res8[j];
    res8[j]=res9[j];
    res9[j]=Null;
    }
    res9= supres(res9,(i-WhenHHV9),i,HHV9);
    }

    /* Check to ensure the latest addition is in the correct ‘res’ array. */

    if ((NOT(IsEmpty(res9) OR IsEmpty(res8))) AND res9>res8)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res9[j];
    res9[j]=res8[j];
    res8[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res8) OR IsEmpty(res7))) AND res8>res7)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res8[j];
    res8[j]=res7[j];
    res7[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res7) OR IsEmpty(res6))) AND res7>res6)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res7[j];
    res7[j]=res6[j];
    res6[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res6) OR IsEmpty(res5))) AND res6>res5)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res6[j];
    res6[j]=res5[j];
    res5[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res5) OR IsEmpty(res4))) AND res5>res4)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res5[j];
    res5[j]=res4[j];
    res4[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res4) OR IsEmpty(res3))) AND res4>res3)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res4[j];
    res4[j]=res3[j];
    res3[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res3) OR IsEmpty(res2))) AND res3>res2)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res3[j];
    res3[j]=res2[j];
    res2[j]=swap[j];
    }
    }
    if ((NOT(IsEmpty(res2) OR IsEmpty(res1))) AND res2>res1)
    {
    for (j=0; J<BarCount; j++)
    {
    swap[j]=res2[j];
    res2[j]=res1[j];
    res1[j]=swap[j];
    }
    }
    }

    /* Support and resistance arrays ready for plotting. */

    /* Determine which TDST lines are currently being used. */

    supval[0]=sup1;
    supval[1]=sup2;
    supval[2]=sup3;
    supval[3]=sup4;
    supval[4]=sup5;
    supval[5]=sup6;
    supval[6]=sup7;
    supval[7]=sup8;
    supval[8]=sup9;

    resval[0]=res1;
    resval[1]=res2;
    resval[2]=res3;
    resval[3]=res4;
    resval[4]=res5;
    resval[5]=res6;
    resval[6]=res7;
    resval[7]=res8;
    resval[8]=res9;

    /* Hopefully, get a valid support value into the top location. */

    Count=0;
    while (IsEmpty(supval[8]) AND Count<8)
    {
    for (j=0; j<8; j++)
    {
    supval[8-j]=supval[7-j];
    }
    Count=Count+1;
    }

    /* Hopefully, get a valid resistance value into the top location. */

    Count=0;
    while (IsEmpty(resval[8]) AND Count<8)
    {
    for (j=0; j<8; j++)
    {
    resval[8-j]=resval[7-j];
    }
    Count=Count+1;
    }

    /* Record support and resistance values. */

    supinuse=supval[8];
    resinuse=resval[8];

    /* Determine if the current close halts a current support or resistance line. */

    if (TDSeqbuydigits>0 AND (NOT IsEmpty(supinuse[i-1])) AND Close<supinuse[i-1]) supvio=True;
    if (TDSeqselldigits>0 AND (NOT IsEmpty(resinuse[i-1])) AND Close>resinuse[i-1]) resvio=True;

    /* Set flags to indicate completed TD Buy and Sell Countdown sequences. */

    if (i>0)
    {
    BCDind=BCDind[i-1];
    SCDind=SCDind[i-1];

    PreBCDfin=PreBCDfin[i-1];
    CurBCDfin=CurBCDfin[i-1];

    PreSCDfin=PreSCDfin[i-1];
    CurSCDfin=CurSCDfin[i-1];
    }

    /* Check Perl’s Rules for Trading TD Buy Setups Objectively. */

    if (Buy9Req==True)
    {

    /* Perl’s Rule 1: Check for perfected TD Buy Setup. */

    if (Low<Low[i-1])
    tmpval=Low;
    else
    tmpval=Low[i-1];

    if (tmpval<=Low[i-2] AND tmpval<=Low[i-3])
    {

    /* Perl’s Rule 2: Check for TDST support violation. */

    tmpval=0;
    for (j=i-8; j<i+1; j++)
    {
    tmpval=tmpval+supvio[j];
    }

    if (tmpval==0)
    {

    /* Perl’s Rule 3: Check the close of TD Buy Setup bar 9 is in close proximity to TDST support. */
    /* This rule is highly subjective. I have chosen the low of bar 9 to be within one ATR distance of the TDST support. */

    if (NOT IsEmpty(supinuse))
    {
    if ((Low-supinuse)<distance*gapprox)
    {

    /* Perl’s Risk Management: Calculating the TD Risk Level for Trading a TD Buy Setup. */

    TDSeqBuy=True;
    TDSeqbuystop=LLV9-(High[i-WhenLLV9]-LLV9);
    TDSeqbuyrisk=Close-TDSeqbuystop;
    TDSeqbuyreward=resinuse-Close;
    TDSeqbuyrrratio=TDSeqbuyreward/TDSeqbuyrisk;
    }
    }
    }
    }

    /* Initiate setup for TD Buy Countdown. */

    BCDind=BCDind+True;

    /* Check to ensure only two TD Sequential Buy patterns are being considered. */

    if (BCDind>2)
    {
    BCDind=BCDind-1;
    kval=PreBCDstart;
    ResetBSpre(kval,i+1);
    PreBCDfin=False;
    }

    /* Filters That Cancel a Developing TD Buy Countdown. */

    /* 1. If the price action rallies and generates a TD Sell Setup, or */
    /* 2. If the market trades higher and posts a true low above the true high of the prior TD Buy Setup – that is, TDST Resistance. */

    /* The second condition is dealt with later in the program. */

    if (SCDind>0)
    {
    if (SCDind>1)
    {
    SCDind=SCDind-1;
    kval=PreSCDstart;
    ResetSSpre(kval,i+1);
    }

    SCDind=SCDind-1;
    kval=CurSCDstart;
    ResetSScur(kval,i+1);

    }

    PreSCDfin=False;
    CurSCDfin=False;

    /* Determine if another Buy TD Sequential Setup has been initiated before the completion of the previous TD Buy Countdown. */

    if (BCDind==2)
    {

    /* Record details of the previous Buy TD Sequential Setup and Countdown. */

    for (j=CurBCDstart[i-1]; j<i; j++)
    {
    PreBSmaxr[j]=CurBSmaxr[j];
    PreBSminr[j]=CurBSminr[j];
    PreBScnt[j]=CurBScnt[j];
    PreBSmaxrc[j]=CurBSmaxrc[j];
    PreBSminrc[j]=CurBSminrc[j];

    PreBCD[j]=CurBCD[j];
    PreBCDmaxr[j]=CurBCDmaxr[j];
    PreBCDminr[j]=CurBCDminr[j];
    PreBCD8[j]=CurBCD8[j];
    PreBCDtext[j]=CurBCDtext[j];
    PreBCDstart[j]=CurBCDstart[j];
    PreBCDfin[j]=CurBCDfin[j];
    }

    ResetBScur(CurBCDstart[i-1],i);
    }

    /* Record details of the new Buy TD Sequential Setup. */

    CurBCD=0;
    CurBCDmaxr=-999999;
    CurBCDminr=999999;
    CurBCDtext=0;
    CurBCDstart=i;
    }

    /* Check Perl’s Rules for Trading TD Sell Setups Objectively. */

    if (Sell9Req==True)
    {

    /* Perl’s Rule 1: Check for perfected TD Sell Setup. */

    if (High>High[i-1])
    tmpval=High;
    else
    tmpval=High[i-1];

    if (tmpval>=High[i-2] AND tmpval>=High[i-3])
    {

    /* Perl’s Rule 2: Check for TDST resistance violation. */

    tmpval=0;
    for (j=i-8; j<i+1; j++)
    {
    tmpval=tmpval+resvio[j];
    }

    if (tmpval==0)
    {

    /* Perl’s Rule 3: Check the close of TD Sell Setup bar 9 is in close proximity to TDST resistance. */
    /* This rule is highly subjective. I have chosen the high of bar 9 to be within one ATR distance of the TDST resistance. */

    if (NOT IsEmpty(resinuse))
    {
    if ((resinuse-High)<distance*gapprox)
    {

    /* Perl’s Risk Management: Calculating the TD Risk Level for Trading a TD Sell Setup. */

    TDSeqSell=True;
    TDSeqsellstop=HHV9+(HHV9-Low[i-WhenHHV9]);
    TDSeqsellrisk=TDSeqsellstop-Close;
    TDSeqsellreward=Close-supinuse;
    TDSeqsellrrratio=TDSeqsellreward/TDSeqsellrisk;
    }
    }
    }
    }

    /* Initiate setup for TD Sell Countdown. */

    SCDind=SCDind+True;

    /* Check to ensure only two TD Sequential Buy patterns are being considered. */

    if (SCDind>2)
    {
    SCDind=SCDind-1;
    kval=PreSCDstart;
    ResetSSpre(kval,i+1);
    PreSCDfin=False;
    }

    /* Filters That Cancel a Developing TD Sell Countdown. */

    /* 1. If the price action declines and generates a TD Buy Setup, or */
    /* 2. If the market trades lower and posts a true high below the true low of the prior TD Sell Setup – that is, TDST support. */

    /* The second condition is dealt with later in the program. */

    if (BCDind>0)
    {
    if (BCDind>1)
    {
    BCDind=BCDind-1;
    kval=PreBCDstart;
    ResetBSpre(kval,i+1);
    }

    BCDind=BCDind-1;
    kval=CurBCDstart;
    ResetBScur(kval,i+1);

    }

    PreBCDfin=False;
    CurBCDfin=False;

    /* Determine if another Sell TD Sequential Setup has been initiated before the completion of the previous TD Sell Countdown. */

    if (SCDind==2)
    {

    /* Record details of the previous Sell TD Sequential Setup and Countdown. */

    for (j=CurSCDstart[i-1]; j<i; j++)
    {
    PreSSmaxr[j]=CurSSmaxr[j];
    PreSSminr[j]=CurSSminr[j];
    PreSScnt[j]=CurSScnt[j];
    PreSSmaxrc[j]=CurSSmaxrc[j];
    PreSSminrc[j]=CurSSminrc[j];

    PreSCD[j]=CurSCD[j];
    PreSCDmaxr[j]=CurSCDmaxr[j];
    PreSCDminr[j]=CurSCDminr[j];
    PreSCD8[j]=CurSCD8[j];
    PreSCDtext[j]=CurSCDtext[j];
    PreSCDstart[j]=CurSCDstart[j];
    PreSCDfin[j]=CurSCDfin[j];
    }

    ResetSScur(CurSCDstart[i-1],i);
    }

    /* Record details of the new Sell TD Sequential Setup. */

    CurSCD=0;
    CurSCDmaxr=-999999;
    CurSCDminr=999999;
    CurSCDtext=0;
    CurSCDstart=i;
    }

    /* Perl’s Rules for trading TD Countdowns. */
    /* Check to see if a TD Buy Countdown is being processed. */

    if (BCDind>0)
    {
    if (BCDind>1)
    {

    /* Record details of the ongoing (previous) Buy TD Sequential Setup. */

    PreBSmaxr=PreBSmaxr[i-1];
    PreBSminr=PreBSminr[i-1];
    PreBScnt=PreBScnt[i-1];
    PreBSmaxrc=PreBSmaxrc[i-1];
    PreBSminrc=preBSminrc[i-1];

    /* Check to see if the ongoing (previous) TD Buy Countdown is still in progress and record details. */

    PreBCDstart=PreBCDstart[i-1];
    PreBCD=PreBCD[i-1]+Buyconseccloses;
    PreBCDmaxr=PreBCDmaxr[i-1];
    PreBCDminr=PreBCDminr[i-1];
    if (PreBCDminr>Low AND PreBCD>0)
    {
    PreBCDmaxr=High;
    PreBCDminr=Low;
    }
    PreBCD8=PreBCD8[i-1];
    if (PreBCD==8 AND PreBCD[i-1]!=8) PreBCD8=Close;

    /* Perl’s Rules to Complete a TD Buy Countdown. */
    /* 1. The Low of TD Buy Countdown bar 13 must be less than, or equal to, the close of TD Buy Countdown bar 8. */
    /* 2. The close of TD Buy Countdown bar 13 must be less than, or equal to, the low two bars earlier. */

    if (Buyconseccloses==True)
    {
    if (PreBCD<13)
    {
    PreBCDtext=PreBCD;
    }
    else
    {
    if (PreBCD>12 AND Low<=PreBCD8)
    {
    PreBCDtext=13;
    BCDplot=PreBCDtext;

    /* Perl’s Risk Management for a TD Buy Countdown. */

    BCDrisk=PreBCDminr-(PreBCDmaxr-PreBCDminr);

    kval=PreBCDstart;
    ResetBSpre(kval,i+1);
    BCDind=BCDind-1;
    PreBCDfin=i;
    }
    else
    {
    PreBCDtext=43; // Deferred Countdown print “+”.
    }
    }
    }
    }

    /* Record details of the current Buy TD Sequential Setup. */

    if (CurBCDmaxr<0)
    {
    CurBSmaxr=BSmaxr;
    CurBSminr=BSminr;
    CurBScnt=BScnt;
    CurBSmaxrc=BSmaxrc;
    CurBSminrc=BSminrc;

    /* Record details of the current TD Buy Countdown. */

    CurBCD=CurBCD+Buyconseccloses;
    if (Buyconseccloses==False)
    {
    CurBCDmaxr=0;
    }
    else
    {
    CurBCDmaxr=High;
    CurBCDminr=Low;
    }
    }
    else
    {

    /* Record details of the current Buy TD Sequential Setup. */

    if (BSetupind==True)
    {
    CurBSmaxr=BSmaxr;
    CurBSminr=BSminr;
    CurBScnt=BScnt;
    CurBSmaxrc=BSmaxrc;
    CurBSminrc=BSminrc;
    }
    else
    {
    CurBSmaxr=CurBSmaxr[i-1];
    CurBSminr=CurBSminr[i-1];
    CurBScnt=CurBScnt[i-1];
    CurBSmaxrc=CurBSmaxrc[i-1];
    CurBSminrc=CurBSminrc[i-1];
    }

    /* Record details of the current TD Buy Countdown. */

    CurBCDstart=CurBCDstart[i-1];
    CurBCD=CurBCD[i-1]+Buyconseccloses;
    CurBCDmaxr=CurBCDmaxr[i-1];
    CurBCDminr=CurBCDminr[i-1];
    if (CurBCDminr>Low AND CurBCD>0)
    {
    CurBCDmaxr=High;
    CurBCDminr=Low;
    }
    CurBCD8=CurBCD8[i-1];
    if (CurBCD==8 AND CurBCD[i-1]!=8) CurBCD8=Close;
    }

    /* Perl’s Rules to Complete a TD Buy Countdown. */
    /* 1. The Low of TD Buy Countdown bar 13 must be less than, or equal to, the close of TD Buy Countdown bar 8. */
    /* 2. The close of TD Buy Countdown bar 13 must be less than, or equal to, the low two bars earlier. */

    if (Buyconseccloses==True)
    {
    if (CurBCD<13)
    {
    CurBCDtext=CurBCD;
    }
    else
    {
    if (CurBCD>12 AND Low<=CurBCD8)
    {
    CurBCDtext=13;
    BCDplot=CurBCDtext;

    /* Perl’s Risk Management for a TD Buy Countdown. */

    BCDrisk=CurBCDminr-(CurBCDmaxr-CurBCDminr);
    BCDrisk[i-1]=CurBCDminr;

    kval=CurBCDstart;
    ResetBScur(kval,i+1);
    BCDind=BCDind-1;
    CurBCDfin=i;
    }
    else
    {
    CurBCDtext=43; // Deferred Countdown use “+” sign.
    }
    }
    }

    /* Filters That Cancel a Developing TD Buy Countdown. */
    /* 1. If the price action rallies and generates a TD Sell Setup, or */
    /* 2. If the market trades higher and posts a true low above the true high of the prior TD Buy Setup – that is, TDST Resistance. */

    /* The first condition is dealt with earlier in the program. */

    if (Low>HHV9[CurBCDstart] AND CurBCDstart>0)
    {
    BCDind=BCDind-1;
    kval=CurBCDstart;
    ResetBScur(kval,i+1);

    /* If we have an ongoing (previous) TD Buy Countdown then, make it current. */

    if (BCDind>0)
    {
    kval=PreBCDstart;
    CopyBSpre(kval,i+1);
    ResetBSpre(kval,i+1);
    }
    }

    /* TD Buy Countdown Cancellation and Recycle Qualifiers. */

    if (BCDind>1 AND BSetupind==False AND BSetupind[i-1]==True)
    {

    /* TD Buy Countdown Cancellation Qualifier 1. */

    /* If the size of the true range of the most recently completed TD Buy Setup is equal to, or greater than, */
    /* the size of the previous TD Buy Setup, but less than 1.618 times it’s size then, */
    /* a TD Setup Recycle will occcur; that is, whichever TD Buy Setup has the larger true range will become */
    /* the active TD Buy Setup. */

    TRcur=CurBSmaxr-CurBSminr;
    TRpre=PreBSmaxr-PreBSminr;
    if (TRcur>=TRpre AND TRcur<1.618*TRpre)
    {
    if (TRcur>TRpre)
    {

    /* Reset the TD Buy Setup previous arrays. */

    BCDind=BCDind-1;
    kval=PreBCDstart;
    ResetBSpre(kval,i+1);
    }
    else
    {
    BCDind=BCDind-1;
    kval=CurBCDstart;
    ResetBSCur(kval,i+1);

    kval=PreBCDstart;
    CopyBSpre(kval,i+1);
    ResetBSpre(kval,i+1);
    }
    }

    /* TD Buy Countdown Cancellation Qualifier 2 (a TD Buy Setup Within a TD Buy Setup). */

    /* If the market has completed a TD Buy Setup that has a closing range within the true range */
    /* of the prior TD Buy Setup, without recording a TD Sell Setup between the two, and if */
    /* the current TD buy Setup has a price extreme within the true range of the prior TD Buy Setup, then */
    /* the prior TD BUY Setup is the active TD Setup, and the TD Buy Countdown relating to it remains intact. */

    if (BCDind>1 AND CurBSmaxrc<PreBSmaxr AND CurBSminrc>PreBSminr AND (CurBSmaxr<PreBSmaxr OR CurBSminr>PreBSminr))
    {
    BCDind=BCDind-1;
    kval=CurBCDstart;
    ResetBSCur(kval,i+1);

    kval=PreBCDstart;
    CopyBSpre(kval,i+1);
    ResetBSpre(kval,I+1);
    }
    }

    /* TD Buy Countdown Recycle Qualifier. */

    /* An ‘R’ will appear when a TD Buy Setup that began before, on, or after the completion of a developing TD Buy Countdown, */
    /* but prior to a bullish TD Price Flip, extends to eighteen bars – that is, eighteen closes, with each one less than than */
    /* the close four price bars earlier. */

    if (CurBScnt==18 AND CurBScnt[i-1]!=18)
    {
    BCDplot=82; // Recycle Qualifier use the letter “R”.
    }

    /* Requirements for Validation of a TD Sequential 9-13-9 Buy Count. */

    /* 1. The TD Buy Setup must not begin before or on the same price bar as the completed TD Buy Countdown. */
    /* 2. The ensuing bullish TD Buy Setup must be preceded by a TD price flip, and */
    /* 3. No complted TD Sell Setup should occur prior to the appearence of the TD Buy Setup. */

    if (CurBCDfin>0 AND TDSeqbuydigits==9)
    {
    if (CurBCDfin<(i-8))
    {
    BCDplot=9139;

    /* Risk Management for the TD Sequential 9-13-9 */

    /* Subtract the true range of the price bar with the lowest true low in the TD Buy Countdown */
    /* and ensuing TD Buy Setup from the true low of that bar. */

    if (BCDrisk[CurBCDfin-1]<LLV9)
    {
    BCDrisk=BCDrisk[CurBCDfin];
    }
    else
    {
    BCDrisk=LLV9-(High[i-whenLLV9]-LLV9);
    }
    }
    CurBCDfin=False;
    }
    }

    /* Check to see if a TD Sell Countdown is being processed. */

    if (SCDind>0)
    {
    if (SCDind>1)
    {

    /* Record details of the ongoing (previous) Sell TD Sequential Setup. */

    PreSSmaxr=PreSSmaxr[i-1];
    PreSSminr=PreSSminr[i-1];
    PreSScnt=PreSScnt[i-1];
    PreSSmaxrc=PreSSmaxrc[i-1];
    PreSSminrc=preSSminrc[i-1];

    /* Check to see if the ongoing (previous) TD Sell Countdown is still in progress and record details. */

    PreSCDstart=PreSCDstart[i-1];
    PreSCD=PreSCD[i-1]+Sellconseccloses;
    PreSCDmaxr=PreSCDmaxr[i-1];
    PreSCDminr=PreSCDminr[i-1];
    if (PreSCDmaxr<High AND PreSCD>0)
    {
    PreSCDmaxr=High;
    PreSCDminr=Low;
    }
    PreSCD8=PreSCD8[i-1];
    if (PreSCD==8 AND PreSCD[i-1]!=8) PreSCD8=Close;

    /* Perl’s Rules to Complete a TD Sell Countdown. */
    /* 1. The High of TD Sell Countdown bar 13 must be greater than, or equal to, the close of TD Sell Countdown bar 8. */
    /* 2. The close of TD Sell Countdown bar 13 must be greater than, or equal to, the high two bars earlier. */

    if (Sellconseccloses==True)
    {
    if (PreSCD<13)
    {
    PreSCDtext=PreSCD;
    }
    else
    {
    if (PreSCD>12 AND High>=PreSCD8)
    {
    PreSCDtext=13;
    SCDplot=PreSCDtext;

    /* Perl’s Risk Management for a TD Buy Countdown. */

    SCDrisk=PreSCDmaxr+(PreSCDmaxr-PreSCDminr);

    kval=PreSCDstart;
    ResetSSpre(kval,i+1);
    SCDind=SCDind-1;
    PreSCDfin=i;
    }
    else
    {
    PreSCDtext=43;
    }
    }
    }
    }

    /* Record details of the current Sell TD Sequential Setup. */

    if (CurSCDmaxr<0)
    {
    CurSSmaxr=SSmaxr;
    CurSSminr=SSminr;
    CurSScnt=SScnt;
    CurSSmaxrc=SSmaxrc;
    CurSSminrc=SSminrc;

    /* Record details of the current TD Sell Countdown. */

    CurSCD=CurSCD+Sellconseccloses;
    if (Sellconseccloses==False)
    {
    CurSCDmaxr=0;
    }
    else
    {
    CurSCDmaxr=High;
    CurSCDminr=Low;
    }
    }
    else
    {

    /* Record details of the current Sell TD Sequential Setup. */

    if (SSetupind==True)
    {
    CurSSmaxr=SSmaxr;
    CurSSminr=SSminr;
    CurSScnt=SScnt;
    CurSSmaxrc=SSmaxrc;
    CurSSminrc=SSminrc;
    }
    else
    {
    CurSSmaxr=CurSSmaxr[i-1];
    CurSSminr=CurSSminr[i-1];
    CurSScnt=CurSScnt[i-1];
    CurSSmaxrc=CurSSmaxrc[i-1];
    CurSSminrc=CurSSminrc[i-1];
    }

    /* Record details of the current TD Sell Countdown. */

    CurSCDstart=CurSCDstart[i-1];
    CurSCD=CurSCD[i-1]+Sellconseccloses;
    CurSCDmaxr=CurSCDmaxr[i-1];
    CurSCDminr=CurSCDminr[i-1];
    if (CurSCDmaxr<High AND CurSCD>0)
    {
    CurSCDmaxr=High;
    CurSCDminr=Low;
    }
    CurSCD8=CurSCD8[i-1];
    if (CurSCD==8 AND CurSCD[i-1]!=8) CurSCD8=Close;
    }

    /* Perl’s Rules to Complete a TD Sell Countdown. */
    /* 1. The high of TD Sell Countdown bar 13 must be greater than, or equal to, the close of TD Sell Countdown bar 8. */
    /* 2. The close of TD Sell Countdown bar 13 must be greater than, or equal to, the high two bars earlier. */

    if (Sellconseccloses==True)
    {
    if (CurSCD<13)
    {
    CurSCDtext=CurSCD;
    }
    else
    {
    if (CurSCD>12 AND High>=CurSCD8)
    {
    CurSCDtext=13;
    SCDplot=CurSCDtext;

    /* Perl’s Risk Management for a TD Buy Countdown. */

    SCDrisk=CurSCDmaxr+(CurSCDmaxr-CurSCDminr);
    SCDrisk[i-1]=CurSCDmaxr;

    kval=CurSCDstart;
    ResetSScur(kval,i+1);
    SCDind=SCDind-1;
    CurSCDfin=i;
    }
    else
    {
    CurSCDtext=43; // Deferred Countdown use “+” sign.
    }
    }
    }

    /* Filters That Cancel a Developing TD Sell Countdown. */
    /* 1. If the price action declines and generates a TD Buy Setup, or */
    /* 2. If the market trades lower and posts a true high below the true low of the prior TD Sell Setup – that is, TDST support. */

    /* The first condition is dealt with earlier in the program. */

    if (High<LLV9[CurSCDstart] AND CurSCDstart>0)
    {
    SCDind=SCDind-1;
    kval=CurSCDstart;
    ResetSScur(kval,i+1);

    /* If we have an ongoing (previous) TD Sell Countdown then, make it current. */

    if (SCDind>0)
    {
    kval=PreSCDstart;
    CopySSpre(kval,i+1);
    ResetSSpre(kval,i+1);
    }
    }

    /* TD Sell Countdown Cancellation and Recycle Qualifiers. */

    if (SCDind>1 AND SSetupind==False AND SSetupind[i-1]==True)
    {

    /* TD Sell Countdown Cancellation Qualifier 1. */

    /* If the size of the true range of the most recently completed TD Sell Setup is equal to, or greater than, */
    /* the size of the previous TD Sell Setup, but less than 1.618 times it’s size then, */
    /* a TD Setup Recycle will occcur; that is, whichever TD Sell Setup has the larger true range will become */
    /* the active TD Sell Setup. */

    TRcur=CurSSmaxr-CurSSminr;
    TRpre=PreSSmaxr-PreSSminr;
    if (TRcur>=TRpre AND TRcur<1.618*TRpre)
    {
    if (TRcur>TRpre)
    {

    /* Reset the TD Sell Setup previous arrays. */

    SCDind=SCDind-1;
    kval=PreSCDstart;
    ResetSSpre(kval,i+1);
    }
    else
    {
    SCDind=SCDind-1;
    kval=CurSCDstart;
    ResetSSCur(kval,i+1);

    kval=PreSCDstart;
    CopySSpre(kval,i+1);
    ResetSSpre(kval,i+1);
    }
    }

    /* TD Sell Countdown Cancellation Qualifier 2 (a TD Sell Setup Within a TD Sell Setup). */

    /* If the market has completed a TD Sell Setup that has a closing range within the true range */
    /* of the prior TD Sell Setup, without recording a TD Buy Setup between the two, and if */
    /* the current TD Sell Setup has a price extreme within the true range of the prior TD Buy Setup, then */
    /* the prior TD Sell Setup is the active TD Setup, and the TD Sell Countdown relating to it remains intact. */

    if (SCDind>1 AND CurSSmaxrc<PreSSmaxr AND CurSSminrc>PreSSminr AND (CurSSmaxr<PreSSmaxr OR CurSSminr>PreSSminr))
    {
    SCDind=SCDind-1;
    kval=CurSCDstart;
    ResetSSCur(kval,i+1);

    kval=PreSCDstart;
    CopySSpre(kval,i+1);
    ResetSSpre(kval,i+1);
    }
    }

    /* TD Buy Countdown Recycle Qualifier. */

    /* An ‘R’ will appear when a TD Sell Setup that began before, on, or after the completion of a developing TD Sell Countdown, */
    /* but prior to a bearish TD Price Flip, extends to eighteen bars – that is, eighteen closes, with each one greater than than */
    /* the close four price bars earlier. */

    if (CurSScnt==18 AND CurSScnt[i-1]!=18)
    {
    SCDplot=82; // Recycle Qualifier use the letter “R”.
    }

    /* Requirements for Validation of a TD Sequential 9-13-9 Sell Count. */

    /* 1. The TD Sell Setup must not begin before or on the same price bar as the completed TD Sell Countdown. */
    /* 2. The ensuing bullish TD Sell Setup must be preceded by a TD price flip, and */
    /* 3. No completed TD Buy Setup should occur prior to the appearence of the TD Sell Setup. */

    if (CurSCDfin>0 AND TDSeqselldigits==9)
    {
    if (CurSCDfin<(i-8))
    {
    SCDplot=9139;

    /* Risk Management for the TD Sequential 9-13-9 */

    /* Add the true range of the price bar with the highest true high in the TD Sell Countdown */
    /* and ensuing TD Sell Setup to the true high of that bar. */

    if (SCDrisk[CurSCDfin-1]>HHV9)
    {
    SCDrisk=SCDrisk[CurSCDfin];
    }
    else
    {
    SCDrisk=HHV9+(HHV9-Low[i-WhenHHV9]);
    }
    }
    CurSCDfin=False;
    }
    }
    }

    /* Sort plot area */

    Lowestlow=LowestVisibleValue(Low);
    Highesthigh=HighestVisibleValue(High);

    Plotrange=Highesthigh-Lowestlow;
    Plotlow=IIf(Plotall==False,(Lowestlow-(Plotpercent/100*Plotrange)),0);
    Plothigh=IIf(Plotall==False,(Highesthigh+(Plotpercent/100*Plotrange)),999999);

    /* perform plot routines. */

    Plot(C, “”, -1, styleCandle);

    /* Plot red buy digits and pink Countdown digits. */

    PlotShapes( IIf( BCDplot==13, shapeUpArrow, IIf(BCDplot==9139, shapeHollowUpArrow, shapeNone)), colorDarkRed,0,IIf(BCDplot>0,Low,High));

    for (i=0; i<BarCount; i++)
    {
    dist1 = reddist*distance;
    if (TDSeqbuydigits>0) PlotText( ” ” + NumToStr(TDSeqbuydigits[ i ],1.0), i, H[ i ]+dist1, colorRed );

    if (BCDplot==82) PlotText(“R”,i,IIf(TDSeqbuydigits>0,H+2*dist1,H+dist1), colorDarkRed);

    if (BCDind>1)
    {
    if (PreBCDtext>0 AND PreBCDtext<13) PlotText(” ” + NumToStr(PreBCDtext[ i ],1.0),IIf(PreBCDtext>9,i-0.5,i),IIf(TDSeqbuydigits>0,H+2*dist1,H+dist1), colorPink);
    if (PreBCDtext==43) PlotText(“+”,i+0.25,IIf(TDSeqbuydigits>0,H+2*dist1,H+dist1), colorPink);
    }
    if (BCDind==1)
    {
    if (CurBCDtext>0 AND CurBCDtext<13) PlotText(” ” + NumToStr(CurBCDtext[ i ],1.0),IIf(CurBCDtext>9,i-0.5,i),IIf(TDSeqbuydigits>0,H+2*dist1,H+dist1), colorDarkRed);
    if (CurBCDtext==43) PlotText(“+”,i+0.25,IIf(TDSeqbuydigits>0,H+2*dist1,H+dist1), colorDarkRed);
    }

    }

    /* plot blue sell digits. */

    PlotShapes( IIf( SCDplot==13, shapeDownArrow, IIf(SCDplot==9139, shapeHollowDownArrow, shapeNone)), colorIndigo,0,IIf(SCDplot>0,High,Low));

    for (i=0; i<BarCount; i++)
    {
    dist1 = bluedist*distance;
    if (TDSeqselldigits>0) PlotText( ” ” + NumToStr(TDSeqselldigits[ i ],1.0), i, L[ i ]-dist1, colorBlue );

    if (SCDplot==82) PlotText(“R”,i,IIf(TDSeqselldigits>0,L-2*dist1,L-dist1), colorIndigo);

    if (SCDind>1)
    {
    if (PreSCDtext>0 AND PreSCDtext<13) PlotText(” ” + NumToStr(PreSCDtext[ i ],1.0),IIf(PreSCDtext>9,i-0.5,i),IIf(TDSeqselldigits>0,L-2*dist1,L-dist1), colorTurquoise);
    if (PreSCDtext==43) PlotText(“+”,i+0.25,IIf(TDSeqselldigits>0,L-2*dist1,L-dist1), colorTurquoise);
    }
    if (SCDind==1)
    {
    if (CurSCDtext>0 AND CurSCDtext<13) PlotText(” ” + NumToStr(CurSCDtext[ i ],1.0),IIf(CurSCDtext>9,i-0.5,i),IIf(TDSeqselldigits>0,L-2*dist1,L-dist1), colorIndigo);
    if (CurSCDtext==43) PlotText(“+”,i+0.25,IIf(TDSeqselldigits>0,L-2*dist1,L-dist1), colorIndigo);
    }
    }

    PlotShapes( IIf( TDSeqBuy, shapeUpArrow, shapeNone ), colorYellow,0,IIf(TDSeqbuy,Low,High));
    PlotShapes( IIf( TDSeqsell, shapeDownArrow, shapeNone ), colorYellow,0,IIf(TDSeqsell,High,Low));
    //PlotShapes( IIf( supvio, IIf(supvio, shapeHollowDownTriangle, shapeUpTriangle), shapeNone ), colorYellow,0,IIf(supvio,High,Low));
    //PlotShapes( IIf( resvio, IIf(resvio, shapeHollowUpTriangle, shapeDownTriangle), shapeNone ), colorYellow,0,IIf(resvio,Low,High));

    Plot(IIf(res1<Plothigh,res1,Null),”res1″,colorOrange,styleLine);
    Plot(IIf(res2<Plothigh,res2,Null),”res2″,colorYellow,styleLine);
    Plot(IIf(res3<Plothigh,res3,Null),”res3″,colorBlue,styleLine);
    Plot(IIf(res4<Plothigh,res4,Null),”res4″,colorGreen,styleLine);
    Plot(IIf(res5<Plothigh,res5,Null),”res5″,colorRed,styleLine);
    Plot(IIf(res6<Plothigh,res6,Null),”res6″,colorWhite,styleLine);
    Plot(IIf(res7<Plothigh,res7,Null),”res7″,colorBrown,styleLine);
    Plot(IIf(res8<Plothigh,res8,Null),”res8″,colorIndigo,styleLine);
    Plot(IIf(res9<Plothigh,res9,Null),”res9″,colorDarkGreen,styleLine);
    Plot(IIf(sup1>PlotLow,sup1,Null),”sup1″,colorOrange,styleLine);
    Plot(IIf(sup2>PlotLow,sup2,Null),”sup2″,colorYellow,styleLine);
    Plot(IIf(sup3>PlotLow,sup3,Null),”sup3″,colorBlue,styleLine);
    Plot(IIf(sup4>PlotLow,sup4,Null),”sup4″,colorGreen,styleLine);
    Plot(IIf(sup5>PlotLow,sup5,Null),”sup5″,colorRed,styleLine);
    Plot(IIf(sup6>PlotLow,sup6,Null),”sup6″,colorWhite,styleLine);
    Plot(IIf(sup7>PlotLow,sup7,Null),”sup7″,colorBrown,styleLine);
    Plot(IIf(sup8>PlotLow,sup8,Null),”sup8″,colorIndigo,styleLine);
    Plot(IIf(sup9>PlotLow,sup9,Null),”sup9″,colorDarkGreen,styleLine);

    /* Automatic Analysis Explore Routines. */

    /* Setup Column Information. */

    NumColumns=8;
    Column0=IIf(TDSeqBuy==True,True,False);
    Column1=IIf(BCDplot==13,True,False);
    Column2=IIf(BCDplot==9139,True,False);
    Column3=IIf(BCDplot==82,True,False);
    Column4=IIf(TDSeqSell==True,True,False);
    Column5=IIf(SCDplot==13,True,False);
    Column6=IIf(SCDplot==9139,True,False);
    Column7=IIf(SCDplot==82,True,False);

    Column0Name = “TDSeq Buy “;
    Column1Name = “BCD 13 “;
    Column2Name = “BCD 9-13-9 “;
    Column3Name = “TDST Buy ‘R’ “;
    Column4Name = “TDSeq Sell “;
    Column5Name = “SCD 13 “;
    Column6Name = “SCD 9-13-9 “;
    Column7Name = “TDST Sell ‘R’ “;

    Filter= IIf(TDSeqBuy==True OR BCDplot==13 OR BCDplot==9139 OR BCDplot==82,True,False) OR IIf(TDSeqSell==True OR SCDplot==13 OR SCDplot==9139 OR SCDplot==82,True,False);

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Title = “{{DATE}} – “+Name()+” (“+ FullName()+ “) – “+” Open=”+O+”, High=”+H+”, Low=”+L+”, Close=”+C+StrFormat(” (%.2f %.1f%%) “,IIf(ROC(C,1)==0,0,C-Ref(C,-1)),SelectedValue( ROC( C, 1 )))+
    “\n”+EncodeColor(colorBlue) + WriteIf(TDSeqBuy==True, “\nPotential TDST Buy : Risk= ” + WriteVal(TDSeqbuyrisk,8.2) + ” Reward= ” + WriteVal(TDSeqbuyreward,8.2) + ” Reward Risk Ratio= ” + WriteVal(TDSeqbuyrrratio,8.2) + ” Stop @ ” + WriteVal(TDSeqbuystop,8.2),””) +
    “”+EncodeColor(colorRed) + WriteIf(TDSeqsell==True, “\nPotential TDST Short : Risk= ” + WriteVal(TDSeqsellrisk,8.2) + ” Reward= ” + WriteVal(TDSeqsellreward,8.2) + ” Reward Risk Ratio= ” + WriteVal(TDSeqsellrrratio,8.2) + ” Stop @ ” + WriteVal(TDSeqsellstop,8.2),””) +
    “\n”+EncodeColor(colorBlue) + WriteIf(BCDplot==13, “\nBuy CD 13 trade : Stop loss at ” + WriteVal(BCDRisk,8.2) + ” Risk is ” + WriteVal(Close-BCDRisk,8.2),””) +
    “”+EncodeColor(colorBlue) + WriteIf(BCDplot==9139, “\nBuy CD 9-13-9 trade : Stop loss at ” + WriteVal(BCDRisk,8.2) + ” Risk is ” + WriteVal(Close-BCDRisk,8.2),””) +
    “\n”+EncodeColor(colorRed) + WriteIf(SCDplot==13, “\nSell CD 13 trade : Stop loss at ” + WriteVal(SCDRisk,8.2) + ” Risk is ” + WriteVal(SCDRisk-Close,8.2),””) +
    “”+EncodeColor(colorRed) + WriteIf(SCDplot==9139, “\nSell CD 9-13-9 trade : Stop loss at ” + WriteVal(SCDRisk,8.2) + ” Risk is ” + WriteVal(SCDRisk-Close,8.2),””) +
    “\n”+EncodeColor(colorGold)+” “+WriteVal(BarCount)+” =BarCount” + ” bar Number = ” + WriteVal(Cum(1)-1,8.0);

    _SECTION_END() ;

    2 users thanked author for this post.
  • #17885

    marvin
    Participant

    ผมต้องทำยังไงบ้างครับ

    พี่มีไลน์ไหหมครับ

    เฟสผม kazamidori loso

    ขอไลนพี่หน่อยครับ เผื่อขอสอบถาม

  • #17913

    Akee
    Participant

    แนะนำ
    1. ใช้ Amibroker
    2. การใช้งานทางชมรมมีแนะนำเบื้องต้นใน YouTube
    3. http://www.wisestocktrader.com/ สูตรต่างๆเอาไว้เพื่อศึกษา

  • #22994

    rae
    Participant

    ผมรบกวนถามครับว่า จะ copy สูตรไปลงในโปรแกรมอย่างไรครับ

     

  • #23005

    dreamscat
    Keymaster

    ดูตัวอย่างจาก vdo นี้ก็ได้ครับ

    1 user thanked author for this post.
    rae
  • #23375

    rae
    Participant

    ขอบคุณครับ นานๆ ผมจะเข้ามา log in

  • #23376

    rae
    Participant

    ขอบคุณครับ

  • #23395

    rae
    Participant

    ผมรบกวนสอบถามครับ ว่าจากในรูปนี้จะแก้ไขอย่างไรครับ

     

    Attachments:
    You must be logged in to view attached files.
  • #23422

    dreamscat
    Keymaster

    ลองเปลี่ยนเครื่องหมาย ? เป็น ” แทนดูนะครับ

    • This reply was modified 2 months ago by  dreamscat.
  • #23454

    tadisake
    Participant

    https://www.wisestocktrader.com/indicator_parts/3716.txt

    ตามlink นี้เลยครับ

You must be logged in to reply to this topic.