{Apprentice : DiNapoli Levels from set date last modification 26 Aug 2004 } Input: StDate(1040801), { starting date } StTime(0), { starting time } EndDate(0), Direct(1), { direction 1-UP, 2 - DOWN } NBars(3), { CMode=0 - Percent of price to define swing } { CMode=1 - Multiplier of 21 bar StdDev } { CMode=2 - Multiplier of 21 bar ATR } { CMode=3 - Number Bars for Swing_Lee Type } SMode(3), Lev(3), { lev=1 : use 23.6 & 76.4; } { lev=2 : use 0.33 &0.667; } { lev=3 : use 0.382 &0.618; } { lev=3 : use 0.5 & 0.5 } DrawText(False); { annotate lines with text } vars: cd(0),idx(0),cBar(0), Focus(0),tmp(0),price(0); array: PtPrice[100](0),PointDate[100](0),PointTime[100](0),PointDir[100](0),level[4](0); if BarNumber=1 then begin level[1]=0.236; level[2]=0.333; level[3]=0.382; level[4]=0.5; end; { set starting focus} if (date[1]=stdate and DataCompression >1) or (DataCompression=1 and ((date[1]=stdate and time[1]=StDate and time>=StTime))) then begin if direct=1 then begin focus=H; ptPrice[idx]=l; Pointdate[idx]=date; PointTime[idx]=time; PointDir[idx]=1; end; if direct=-1 then begin focus=L; ptPrice[idx]=H; Pointdate[idx]=date; PointTime[idx]=time; PointDir[idx]=-1; end; end; if date>stdate and (date0 then begin { from up to down } PtPrice[idx]=h[-cd]; Pointdate[idx]=date[-cd]; PointTime[idx]=time[-cd]; PointDir[idx]=1; idx=idx+1; end; {-------------------------------------------------} if direct=1 then begin if H>focus then focus=H; end; if cd>0 and cd[1]<0 then begin { from down to up } PtPrice[idx]=l[cd]; Pointdate[idx]=date[cd]; PointTime[idx]=time[cd]; PointDir[idx]=-1; idx=idx+1; end; if value1<>0 then plot1[cBar]( value1, "Plot1" ) ; Condition1 = FALSE ; if Condition1 then Alert( "" ) ; end; { StDate condition } if LastBarOnChart then begin if direct=1 then begin for tmp=0 to idx begin if PointDir[tmp]=-1 then begin price=focus-(focus-ptprice[tmp])*level[Lev]; value1=TL_new(PointDate[tmp],PointTime[tmp],price,date,time,price); Value1 = TL_SetStyle(value1, tool_dotted); if DrawText=true then Value1 = Text_New(date, time, Price, "S "+NumToStr(price,4)+" "); price=focus-(focus-ptprice[tmp])*(1-level[Lev]); value1=TL_new(PointDate[tmp],PointTime[tmp],price,date,time,price); Value1 = TL_SetStyle(value1, tool_dashed2); if DrawText=true then Value1 = Text_New(date, time, Price, "Big "+NumToStr(price,4)+" "); end; end; value1=TL_new(PointDate[0],PointTime[0],focus,date,time,focus); tl_setcolor(value1,white); end; if direct=-1 then begin for tmp=0 to idx begin if PointDir[tmp]=1 then begin price=focus+(-focus+ptprice[tmp]) * level[Lev]; value1=TL_new(PointDate[tmp],PointTime[tmp],price,date,time,price); Value1 = TL_SetStyle(value1, tool_dotted); if DrawText=true then Value1 = Text_New(date, time, Price, "S "+NumToStr(price,4)+" "); price=focus+(-focus+ptprice[tmp])*(1-level[Lev]); value1=TL_new(PointDate[tmp],PointTime[tmp],price,date,time,price); Value1 = TL_SetStyle(value1, tool_dashed2); if DrawText=true then Value1 = Text_New(date, time, Price, "Big "+NumToStr(price,4)+" "); end; end; value1=TL_new(PointDate[0],PointTime[0],focus,date,time,focus); tl_setcolor(value1,white); end; { now draw zigzags} For tmp=0 to idx-2 begin value1=tl_new(PointDate[tmp],PointTime[tmp],PtPrice[tmp],PointDate[tmp+1],PointTime[tmp+1],PtPrice[tmp+1]); tl_setcolor(value1,red); Value1 = TL_SetStyle(value1, tool_dashed); { print(tmp, " ",PointDate[tmp]," ", PointTime[tmp]," ",PtPrice[tmp]); } end; end;