you can also try fractal and ATR type pivots. They adjust when you change the time frame. I posted these lots of times. Below some code that uses ATR pivots. I just did a replay and seems that the signals are correct but you will have to double check
perBull = Param( "Bullish ATR Period", 20, 1, 150, 1 );
perBear = Param( "Bearish ATR Period", 20, 1, 150, 1 );
multBull = Param( "Bullish ATR Multiple", 2, 1, 4, 0.05 );
multBear = Param( "Bearish ATR Multiple", 2, 1, 4, 0.05 );
tfrm = in1Minute * Interval() / 60 * Param( "Chart Time Frame Factor", 2, 1, 10, 1 );
x = BarIndex();
function ATRtrail_func()
{
tvHigh = C;
tvLow = C;
sup = tvHigh - multBull * ATR( perBull );
res = tvLow + multBear * ATR( perBear );
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
if( C[ i ] > trailstop AND C[ i - 1 ] > trailstop )
trailstop = Max( trailstop, sup[ i ] );
else
if( C[ i ] < trailstop AND C[ i - 1 ] < trailstop )
trailstop = Min( trailstop, res[ i ] );
else
trailstop = IIf( C[ i ] > trailstop, sup[ i ], res[ i ] );
trailARRAY[ i ] = trailstop;
}
return trailARRAY;
}
TimeFrameSet( tfrm );
trBull = multBull * ATR( perBull );
trBear = multBear * ATR( perBear );
trailArray = ATRtrail_func();
ts = IIf( trailArray > C, trailArray, Null ); // dntrend
tl = IIf( trailArray < C, trailArray, Null ); // uptrend
TimeFrameRestore();
ts = TimeFrameExpand( ts, tfrm, expandlast );
tl = TimeFrameExpand( tl, tfrm, expandlast );
lll = LLV( L, BarsSince( !IsEmpty( tl ) ) );
lll = IIf( ts, lll, Null );
trn = ts AND L == lll;
hhh = HHV( H, BarsSince( !IsEmpty( ts ) ) );
hhh = IIf( tl, hhh, Null );
pkn = tl AND H == hhh;
tr = ExRem( Reverse( trn ), Reverse( pkn ) );
pk = ExRem( Reverse( pkn ), Reverse( trn ) );
tr = Reverse( tr );
pk = Reverse( pk );
for( i = 0; i <= 3; i++ )
{
VarSet( "UpperX" + i, ValueWhen( pk, x, i ) );
VarSet( "UpperY" + i, ValueWhen( pk, H, i ) );
VarSet( "LowerX" + i, ValueWhen( tr, x, i ) );
VarSet( "LowerY" + i, ValueWhen( tr, L, i ) );
}
Buy = Cross( H, Ref( UpperY1, -1 ) ) AND Ref( UpperX1, -1 ) <= Ref( LowerX1, -1 ) AND Ref( LowerY1, -1 ) >= Ref( LowerY2, -1 );
Buy = ExRem( Buy, pk );
BuyPrice = Max( O, Ref( UpperY1, -1 ) );
SetChartBkColor( ColorRGB( 0, 0, 0 ) );
SetChartOptions( 0, chartShowArrows | chartShowDates );
Plot( C, "C", colorWhite, styleCandle, Null, Null, 0, 0, 1 );
Plot( UpperY1, "", colorRed, styleLine | styleNoRescale, Null, Null, 0, 0, 1 );
Plot( LowerY1, "", colorGreen, styleLine | styleNoRescale, Null, Null, 0, 0, 1 );
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), ColorRGB( 0, 255, 255 ), 0, L, -10 );
PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), ColorRGB( 255, 255, 255 ), 0, BuyPrice, 0 );
PlotShapes( IIf( pk, shapeSmallCircle, shapeNone ), ColorRGB( 255, 0, 0 ), 0, H, 10 );
PlotShapes( IIf( tr, shapeSmallCircle, shapeNone ), ColorRGB( 0, 255, 0 ), 0, L, -10 );