StyleNoLine for Pivots on Datechange fails

When I tried to avoid the oblique lines on day change
for the drawing of pivot lines by applying the following code

dn = DateNum();
newday = dn != Ref( dn, -1);
MyStyle = IIf(newday,StyleNoline,StyleDashed);

to continue by trying to plot for exemple

Plot(r1,"",colorwhite,MyStyle|styleNoRescale);

I got the error 5 : "4-th argument of the Plot() call has incorrect type.
The function expected a NUMBER here,but found an ARRAY."
Also other trials to achieve this failed, so how could it be done
to get just an empty space on the first bar of the day before the
new pivot line starts ?

@Achalendra, how to accomplish this was recently explained here.

Thank youi for your answer, but this one I also tried already,
I should have started to describbe this one first.
Indeed in this case we obtain an empty space on the first bar
after the day change, but strangely an oblique line develops
now on the last bar of the previous day, without even the condition
being met. The oblique line is just staggered one bar to the left !

@Achalendra that approach shoud work (see this other full working example by @fxshrat).
You are probably doing something else to get the oblique line.

The best way to get help is to post you full formula.

The whole code is very long as I added also Fibs to 6 pivot levels
but I extracted the essential sequences here. I changed the styledashed to stylethick to show it more clearly, but also
stylestaircase doesn't change the problem...

_SECTION_BEGIN( "Pivots Test" );
dn = DateNum();
newday = dn != Ref( dn, -1);
StartTime  = ParamTime( "Start Time", "00:00:00" );
EndTime   = ParamTime( "END Time", "22:45:00" );
tn = TimeNum();
StartBar = tn == StartTime; 
EndBar = tn == Endtime; 
YesterdayHHinRange = ValueWhen( EndBar, HighestSince( StartBar, High ), 2); 
YesterdayLLinRange = ValueWhen( EndBar, LowestSince( StartBar, Low ), 2); 
YesterdayCinRange = ValueWhen( EndBar, Close, 2 );
Hi = YesterdayHHinRange;
Lo = YesterdayLLinRange;
C1 = YesterdayCinRange;
bp = (Hi + Lo + C1)/3;
cond1 = Day() == Ref(Day(),-1);
Plot(IIf(cond1,bp,Null),"",colorwhite,StyleThick|styleNoRescale);
Title = "";
_SECTION_END();

@Achalendra, since your code generates the pivots based on the endBar, the cond1 should be:

cond1 = tn >= startTime AND tn < endTime;
Plot( iif( cond1, bp, null ), "", colorOrange, styleThick );

Optionally add the same plot, shifting it of 1 bar, to extend it to the endBars:

// using a different color only to see where it is the "extension"`
Plot( iif( cond1, bp, null ), "", colorBlue, styleThick | styleNoLabel | styleNoTitle, null, null, 1 );

(in the posted code the bp values are changing in correspondence of the endBars - this is the reason you saw the 'oblique lines')

Thank you very much !
This resolved indeed perfectly the problem.

1 Like

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