/*[[ Name := SHI_Channel Author := Copyright © 2004, Shurka Link := shurka@pochtamt.ru Notes := Barishpolets Channels Separate Window := No First Color := Red First Draw Type := Symbol First Symbol := 164 Use Second Data :=no Second Color := Blue Second Draw Type := Line Second Symbol := 218 ]]*/ Inputs: AllBars(240);//number of bars counted. 0-all bars counted Inputs: BarsForFract(0);//bars of fractal's "shoulder" Variable: CurrentBar(0), B1(-1),B2(-1),UpDown(0),P1(0),P2(0),PP(0),Step(0); Variable: i(0),AB(300),BFF(0); Variable: ishift(0),iprice(0); SetLoopCount(0); //cycles unlimited if AllBars==0 or Bars0 then BFF=BarsForFract else { Switch Period { case 1: BFF=12; case 5: BFF=48; case 15: BFF=24; case 30: BFF=24; case 60: BFF=12; case 240: BFF=15; case 1440: BFF=10; case 10080: BFF=6; Default: exit; }; }; CurrentBar=2; //start counting from the third bar as the fractal is "pinned down" B1=-1; B2=-1; UpDown=0; While (B1==-1 or B2==-1) & CurrentBar-1 & CurrentBar=Highest(MODE_HIGH,CurrentBar+BFF,BFF*2+1) then { if UpDown==0 then { UpDown=1; B1=CurrentBar; P1=High[B1]; } else { B2=CurrentBar; P2=High[B2]; }; }; CurrentBar++; }; if B1==-1 or B2==-1 then exit; // No fractals have been found in 300 bar range 8-) Step=(P2-P1)/(B2-B1);//step calculated, if positive then the channel is descending P1=P1-B1*Step; B1=0;//price and the 1st bar are being restored to zero //Reference point for opposite trendline ishift=0; iprice=0; if UpDown=1 then { PP=Low[2]-2*Step; for i=3 to B2 {if Low[i]P1 then {ishift=0; iprice=P1;}; if high[1]>P1+Step then {ishift=1; iprice=P1+Step;}; } else { PP=High[2]-2*Step; for i=3 to B2 {if High[i]>PP+Step*i then { PP=High[i]-i*Step;};}; if Low[0]PP then {ishift=0; iprice=PP;}; if high[1]>PP+Step then {ishift=1; iprice=PP+Step;}; }; //Last price and bar to be set on ÀÂ to draw the line to the upmost right P2=P1+AB*Step; B1=Time[B1]; B2=Time[AB]; // 0 (zero) means the channel line remains intact, dot means the channel is broken SetIndexValue(ishift,iprice); MoveObject("TL1",OBJ_TRENDLINE,B2,PP+Step*AB,B1,PP,ForestGreen,2,STYLE_SOLID); MoveObject("TL2",OBJ_TRENDLINE,B2,P2,B1,P1,ForestGreen,2,STYLE_SOLID); MoveObject("MIDL",OBJ_TRENDLINE,B2,(P2+PP+Step*AB)/2,B1,(P1+PP)/2,ForestGreen,1,STYLE_DOT);