Need idea to manage scaling

i plot 400 bar high and 400 bar lows. however the market is trending so high that my 400 bar low is very far away sqewing my charts as you can see here.

i would like to not plot the 400 bar low if its >3 ATR away on the visible chart. I am thinking aloud and any ideas will help me fix it.

sym = "";
SetChartOptions( 0, chartShowArrows | chartShowDates );

sym="DJA";
result=SetForeign( sym, fixup = False, tradeprices = False ) ;
if(result){
Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
 //PlotForeign( sym, sym, ParamColor( "Color", colorCycle ), ParamStyle( "Style" ) | GetPriceStyle() );
 //   PlotForeign( sym, sym, ParamColor( "Color", colorCycle ), ParamStyle( "Style" ) | GetPriceStyle() );
    movingAverageOfInd = EMA( c, 9 );
    Plot( movingAverageOfInd, "movingAverageOfInd", colorYellow, styleLine );
    fourhundredHighLong = Ref( HHV( h, 400 ), -1 );
    fourhundredHighShort = Ref( llv(l, 400 ), -1 );
    Plot( fourhundredHighLong, "400 High", colorWhite, styleLine );
    Plot(fourhundredHighShort, "400 low", colorWhite, styleLine );


Title = " Market chart is " + sym + " " + Name() + " " + FullName();
}
RestorePriceArrays( True ); // <- should match parameter used in SetForeign 

Try it like this, I am using IIF()

atr3 = ATR(3);
fourhundredHighLong = Ref( HHV( h, 400 ), -1 );
fourhundredHighShort = Ref( llv(l, 400 ), -1 );
fourhundredHighLong = IIf( fourhundredHighLong > atr3, atr3, fourhundredHighLong);
fourhundredHighShort = IIf( fourhundredHighShort < atr3, atr3, fourhundredHighShort);
Plot( fourhundredHighLong, "400 High", colorWhite, styleLine );
Plot( fourhundredHighShort, "400 low", colorWhite, styleLine );

@suresh I interpreted your question a bit differently so maybe add something like this,

fourhundredHighShort = Ref( llv(l, 400 ), -1 );
ShortLine = IIf( fourhundredHighShort < (LowestVisibleValue( Low ) - 3*ATR(14) ), Null, fourhundredHighShort );
    
Plot( ShortLine, "400 low", colorWhite, styleLine );
1 Like

Alternatively you can hide the plot without turning it on and off by setting the style to StyleNoRescale

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.