// Downloaded From https://www.WiseStockTrader.com
Title = ("ST - " + Name()+"  " + Date() +"  "+Interval(2) +"  "+ EncodeColor(colorLime)+",Open "+Open +" ,High "+H+" ,Low "+L+" ,Close "+C+" "+"{{VALUES}}");
_SECTION_BEGIN("Trend Oscillator");

period = Param("Period", 13, 1, 240, 1);
mult = Param("Multiplier", 2.5, 1, 240, 0.1);

f=ATR(period);

VS[0] = Close[0]; 
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;

for( i = period+1; i < BarCount; i++ ) 
{ 

vs[i] = vs[i-1];
trend[i] = trend[i-1];
highC[i] = HighC[i-1];
lowc[i] = lowc[i-1];

if ((trend[i]>=0) && ( C[i] <VS[i] ))
{
trend[i] =-1;
HighC[i] = C[i];
lowc[i] = C[i];
}

if ((trend[i]<=0) && (C[i] >VS[i]))
{
trend[i]=1;
HighC[i] = C[i];
lowc[i] = C[i];
} 

if (trend[i]==-1) 
{
if (C[i]<lowc[i]) lowc[i] = C[i];
VS[i]= lowc[i]+ (mult*f[i]);
}


if (trend[i]==1) 
{
if (C[i]>HighC[i]) HighC[i] = C[i];
VS[i]= HighC[i]-(mult*f[i]);
}

} 


Buy=Cross(Trend,0);
Sell=Cross(0, Trend);
Cover=Cross(Trend,0);
Short=Cross(0, Trend);

mkol = IIf( Trend==1, 10, 11);



_SECTION_END();


//---- pivot points
WeekH = TimeFrameGetPrice("H", inWeekly, 0); // yesterweek's high
WeekL = TimeFrameGetPrice("L", inWeekly, 0); // yesterweek's low
WeekC = TimeFrameGetPrice("C", inWeekly, 0); // yesterweek's close
WeekO = TimeFrameGetPrice("O", inWeekly, 0); // current week open

//............camarilla pivots

H5 = (WeekH/WeekL) * WeekC;
H4 = ( (WeekH-WeekL) * (1.1/2) ) + WeekC;
H3 = ( (WeekH-WeekL) * (1.1/4) ) + WeekC;
H2 = ( (WeekH-WeekL) * (1.1/6) ) + WeekC;
H1 = ( (WeekH-WeekL) * (1.1/12) ) + WeekC;

L1 = WeekC - ( (WeekH-WeekL) * (1.1/12) );
L2 = WeekC - ( (WeekH-WeekL) * (1.1/6) ) ;
L3 = WeekC - ( (WeekH-WeekL) * (1.1/4) ) ;
L4 = WeekC - ( (WeekH-WeekL) * (1.1/2) ) ;
L5 = WeekC - (H5 - WeekC);

Pivot = (L1 + H1)/2;

AddColumn(H5,"H5",1.4);
AddColumn(H4,"H4",1.4);
AddColumn(H3,"H3",1.4);
AddColumn(H2,"H2",1.4);
AddColumn(H1,"H1",1.4);
AddColumn(Pivot,"PP",1.4);
AddColumn(L1,"L1",1.4);
AddColumn(L2,"L2",1.4);
AddColumn(L3,"L3",1.4);
AddColumn(L4,"L4",1.4);
AddColumn(L5,"L5",1.4);


// percentage ranges

H3U = H3 + (0.05 * H3);
H3D = H3 - (0.05 * H3);
L3U = L3 + (0.05 * L3);
L3D = L3 - (0.05 * L3);

H4U = H4 + (0.05 * H4);
H4D = H4 - (0.05 * H4);
L4U = L4 + (0.05 * L4);
L4D = L4 - (0.05 * L4);

DayC = TimeFrameGetPrice("C", inDaily, 0); // current day close
DayO = TimeFrameGetPrice("O", inDaily, 0); // current day open
flag = IIf(((DayC < H3U) OR (DayC > H3D) OR (DayC < L3U) OR (DayC > L3D) OR (DayC < H4U) OR (DayC > H4D) OR (DayC < L4U) OR (DayC > L4D) OR (DayO < H3U) OR (DayO > H3D) OR (DayO < L3U) OR (DayO > L3D) OR (DayO < H4U) OR (DayO > H4D) OR (DayO < L4U) OR (DayO > L4D)), 1, 0);

Filter = (Buy OR Sell) AND (flag = 1);