Displace Channel

Hi,

I would like to displace the channels in the following code. However, when I add in
the function “Displacement” the channels do not appear to displace at all.

Below is the code with the Displacement function. Can someone assist me?

Thank you.


CY1 =  Param("Short Cycle Length?" ,10, 1 ,1000 ,1 )/2;
CY2 =  Param("Medium Cycle Length?" ,80, 1 ,1000 ,1 )/2;
M1 =  Param("Short Cycle Multiplyer?" ,1, 0.01 ,10 ,1 );
M2 =  Param("Medium Cycle Multiplyer?" ,3, 0.01 ,10 ,1 );
T1 =  Ref(MA(Close ,CY1 ),CY1/2)+ M1*ATR(CY1 );
B1 =  Ref(MA( Close ,CY1 ),CY1/2)- M1*ATR(CY1 );
T2 =  Ref(MA(Close ,CY2 ),CY2/2)+ M2*ATR(CY2 );
B2 =  Ref(MA( Close ,CY2 ),CY2/2)- M2*ATR(CY2 );
Displacement = Param("Displacement", 1, -50, 50 );

Plot(T1, "", colorLime, 0, 0, Displacement );
Plot(B1, "", colorLime, 0, 0, Displacement );
Plot(T2, "", colorRed, 0, 0, Displacement );
Plot(B2, "", colorRed, 0, 0, Displacement );

GraphXSpace = 5;
_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );

if ( ParamToggle( "Tooltip shows", "All Values|Only Prices" ) )
{
    ToolTip = StrFormat( "Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g (%.1f%%)\nVolume: " + NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
}
_SECTION_END();

hi
read again the function Plot

Plot( array, name, color/barcolor, style = styleLine, minvalue = Null, maxvalue = Null, XShift = 0, Zorder = 0, width = 1 )

so you forgot to place the "Displacement " to the 7th position XShift

your code to work should be like :

Plot(T1, "", colorLime, 0, 0, 0, Displacement );
3 Likes

Thank you very much for your help.