Inputs: Length(12), Strength(1), Price(High);
vars: RsiValue(0);

RsiValue = rsi(Price, Length); 
plot1(RsiValue);
plot2(80);
plot3(20);

Value1=SwingHigh(1, RsiValue, Strength, Strength+1);
Value2=SwingHigh(1, Price, Strength, Strength+1);

//==================== Higher Part ===============================================
Vars : RSIH(0), PriceH(0), D1(0), T1(0);

Value1=SwingHigh(1, RsiValue, Strength, Strength+1);
Value2=SwingHigh(1, Price, Strength, Strength+1);

if value1<>-1 then begin
   RSIH = value1;   //Put the turning value into RSIH 
   D1   = Date;      //for line drawing
   T1   = time[1];   //for line drawing
END;

if value2<>-1 then begin
   PriceH=Value2;   //Put turn point into PriceH
End;

//Non-Sync judgement

If RSIH <RSIH[1] and PriceH>=PriceH[1] then begin
   Value3=arw_new(date,time,high,True);                        //draw an arrow
   Value3=arw_new_self(date,time,RSIH,True);
   value4=tl_new(D1, T1, PriceH, D1[1], T1[1], PriceH[1]);     //Draw Trend line
   value4=tl_new_self(D1, T1, RSIH , D1[1], T1[1], RSIH [1]);  //Draw Trend line
end;


//====================== Lower Part =========================================
Vars : RSIL(0), PriceL(0), D2(0), T2(0);

value11=SwingLow(1, RsiValue, Strength, Strength+1);
Value12=SwingLow(1, Price, Strength, Strength+1);

if value11<>-1 then begin
   RSIL = value11;   //Put the turning value into RSIL
   D2   = Date;      //for line drawing
   T2   = time[1];   //for line drawing
END;

if value12<>-1 then begin
   PriceL=Value12;   //Put turn point into PriceH
End;

//Non-Sync judgement

If RSIL>RSIL[1] and PriceL<=PriceL[1] then begin
   Value13=arw_new(date,time,Low,False);                        //draw an arrow
   Value13=arw_new_self(date,time,RSIL,False);
   value14=tl_new(D2, T2, PriceL, D2[1], T2[1], PriceL[1]);     //Draw Trend line
   value14=tl_new_self(D2, T2, RSIL, D2[1], T2[1], RSIL[1]);    //Draw Trend line
end;