# When plotting with XShift in negative value , Value in title is Empty

Hi Guys,

It may be bugs. I was reading the book "Trading with Ichimoku: A practical guide to low-risk Ichimoku strategies" by Karen Péloille (so far quite interesting) and checking the indicator on Amibroker. Chikou Span (lagging span was missing from indicator). I fiddled around with param according to the book and added Chikou Span in the formula. Strangely in the title, value of Chikou Span is {EMPTY} . I played around and found that if I removed or made the XShift value in Plot() to positive or zero, the value is filled. But when XShift is in negative, the value is {EMPTY}.

``````prds = Param( "Standard Line Periods", 26, 5, 26, 1 );
turn = Param( "Turning Line Periods", 9, 3, 10, 1 );
delay = Param( "Delayed Line Periods", 26, 4, 25, 1 );
span = Param( "Spans Periods", 52, 10, 52, 1 );
Zorder = Param ("Transparentcy",5,0,20,1);

TL = ( HHV( H, turn ) + LLV( L, turn ) ) / 2;
SL = ( HHV( H, prds ) + LLV( L, prds ) ) / 2;
DL = Ref( C, delay );
Sp1 = ( SL + TL ) / 2;
Sp2 = ( HHV( H, span ) + LLV( L, span ) ) / 2;
CS = Close; //Chikou Span

_N( Title = StrFormat( "{{NAME}} - {{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", colorDefault, styleNoTitle | GetPriceStyle() );
Plot( SL, "Kijun-Sen", colorRed, styleThick | styleNoLabel, Null, Null, 0, -(Zorder-2) );
Plot( TL, "Tenkan-Sen", colorGreen, styleThick | styleNoLabel, Null, Null, 0, -(Zorder-2) );
Plot( CS,"Chikou Span",colorBlue,styleDashed | styleNoLabel, Null,Null,-(delay), -(Zorder-3)); //ploting lagging span Chikou Span
color = IIf( Sp1 > Sp2, ParamColor( "Span1 Color", ColorRGB( 0, 255, 0 ) ), ParamColor( "Span2 Color", ColorRGB( 255, 104, 32 ) ) );
PlotOHLC ( Sp1, Sp1, Sp2, Sp2, "Cloud", Color, styleCloud | styleNoLabel, Null, Null, delay, -5 );
``````

@jamesn, as a quick alternative, you can modify your code shifting the array price so it will draw a straight line where now you'll see {empty} values (there it will repeatedly plot the last array value).

``````CS2 = Ref(Close, delay);
Plot( CS2,"Chikou Span 2",colorYellow,styleDashed | styleNoLabel, Null,Null, 0, -(Zorder-1)); //plotting lagging span Chikou Span
``````

Don't forget to get your "verified badge" to show you own AmiBroker.

There are no bugs in AmiBroker.

You are mistaken. XShift works fine. Simply if you use negative XShift (say -5) it means that LAST 5 bars represent the FUTURE. FUTURE is UNKNOWN. Empty means unknown value. And everything is perfect as it should be.

``````Plot( C, "C", colorRed, styleLine );
Plot( C, "5bar XShifted", colorBlue, styleLine, Null, Null, -5 );
``````

2 Likes

Hello Tomasz,

thank you for your reply. Yes, I may be mistaken. In AFL reference the parameter XShift was described as " AFL Function Reference - PLOT

• XShift - allows to visually shift the chart past the last bar." I understand it said it visually shifts the chart, not shifting the value. So there is no future or the past. it is just the value , plotting in the particular position of the chart, in this case it is value of the current closing price. Is my understanding totally wrong?

Yes, to visually shift past last bar XShift should be > 0. If you actually read the manual BEYOND that point you would notice that there is AN EXAMPLE included that shows how to use it and the example uses 10 (positive number).

Taken from manual http://www.amibroker.com/guide/afl/plot.html :

``````// Example 20-bar Moving average shifted 10 bars into the future past the last bar:
Plot(Close,"Close",colorBlack,styleCandle);
Plot(MA(Close,20), "Shifted MA", colorRed, styleLine, Null, Null, 10 );
// Note that shift occurs during plotting AND does NOT affect source array
``````

Moreover, you could add a simple parameter slider:

``````// Example 20-bar Moving average shifted 10 bars into the future past the last bar:
Plot(Close,"Close",colorDefault,styleCandle);
Plot(MA(Close,20), "Shifted MA", colorRed, styleLine, Null, Null, Param("XShift", 0, -10, 10 ) );
// Note that shift occurs during plotting AND does NOT affect source array
``````

And modify XShift in real-time:

1 Like

thank you Tomasz for taking time to answer. Yes I did read beyond that poin to the manual,where I saw the positve value in XShift in example. Ichimoku indicator particular have one component to plot ahead(26 bars ahead) and one behind(26 bars behind). Now I understand XShift was expecting positive value.

Thanks again.

1 Like