Page 1 of 1

Powerlanguage and projection in the future

Posted: 08 Sep 2009
by CrazyNasdaq
Hi,
is there a possibility to project indicators in the future beyond the lastbar on chart without using positive or negative displace ?
I ask this because I'm trying to create a cyclical indicator which projects in the future an hypotetical trend of the market, but I can't plot it beyond the last bar even if its creation doesn't depend on any data in the chart (NOT used open, high, low, close, volume ecc...) . It's a sinewave indicator which starts in a given date and time and moves on in the same way in the future respecting the parameters of lenght and slope given in the inputs panel.
Attached there is a snapshot of what I'm trying to create and then what I've seen on the web using Metastock (the same indicator but maybe with a projection beyond lastbar on chart).
Is there the possibility to project this indicator not only to the last bar on chart, but for example to the maxbarsforward ??
Thank

CraZy

Re: Powerlanguage and projection in the future

Posted: 23 Mar 2011
by TJ
Hi,
is there a possibility to project indicators in the future beyond the lastbar on chart without using positive or negative displace ?
I ask this because I'm trying to create a cyclical indicator which projects in the future an hypotetical trend of the market, but I can't plot it beyond the last bar even if its creation doesn't depend on any data in the chart (NOT used open, high, low, close, volume ecc...) . It's a sinewave indicator which starts in a given date and time and moves on in the same way in the future respecting the parameters of lenght and slope given in the inputs panel.
Attached there is a snapshot of what I'm trying to create and then what I've seen on the web using Metastock (the same indicator but maybe with a projection beyond lastbar on chart).
Is there the possibility to project this indicator not only to the last bar on chart, but for example to the maxbarsforward ??
Thank

CraZy
it can be done...

if you have the formula... just plot it with plot[-1] and the line will go to the next bar, plot it with plot[-2] and the line will go to the bar after, and so on.

Re: Powerlanguage and projection in the future

Posted: 24 Mar 2011
by jek
When I tried Plotxx[-2] a couple of months ago it barked at me.

Have you actually gotten that to work? If so, I may give that another try.

Is there some setting needed to enable it?

Re: Powerlanguage and projection in the future

Posted: 25 Mar 2011
by CrazyNasdaq
I tried it but it doesn't work.
Plotx[-2] is a simple front displace of the indicator but it moves forward the starting point of 2 periods or "N" periods.
I was searching a way to plot in the future a line without moving/displacing the starting point.
The starting point must stay anchored but with Plotx[-2] you move forward the entire line and the starting point too.

Re: Powerlanguage and projection in the future

Posted: 25 Mar 2011
by TJ
I tried it but it doesn't work.
Plotx[-2] is a simple front displace of the indicator but it moves forward the starting point of 2 periods or "N" periods.
I was searching a way to plot in the future a line without moving/displacing the starting point.
The starting point must stay anchored but with Plotx[-2] you move forward the entire line and the starting point too.
No, I am not talking about displace.

A displaced plot simply shift the plot by [-1].

I am talking about a formula... if you have the formula of your "cyclical indicator", you can modify the indicator to plot into the future bars with [-1]....

Re: Powerlanguage and projection in the future

Posted: 25 Mar 2011
by jek
When I tried Plotxx[-2] a couple of months ago it barked at me.
It turns out this worked for a subset of my indicators but failed for some that used bars at multiple time resolutions.

I suspect it is an edge case bug and I will try to submit a simple test case to the PM site.

Re: Powerlanguage and projection in the future

Posted: 25 Mar 2011
by TJ
When I tried Plotxx[-2] a couple of months ago it barked at me.
It turns out this worked for a subset of my indicators but failed for some that used bars at multiple time resolutions.

I suspect it is an edge case bug and I will try to submit a simple test case to the PM site.
you can project as far into the future as there are FREE chart space available.

ie. if there are 50 bars of free space to the right of the current bar, you can make plot[-50], but should not make a plot[-51], otherwise an error will show up.

Re: Powerlanguage and projection in the future

Posted: 25 Mar 2011
by jek
Bingo. Thanks, TJ. I was fooled because the windows that failed had multiple instruments in them and thought that it was the cause.

:)

Re: Powerlanguage and projection in the future

Posted: 25 Mar 2011
by TJ
Bingo. Thanks, TJ. I was fooled because the windows that failed had multiple instruments in them and thought that it was the cause.

:)
YW.

Hope you can post some screenshots to to whet our curiosity.

Re: Powerlanguage and projection in the future

Posted: 26 Mar 2011
by CrazyNasdaq
Sorry, but I don't understand where I should put the string "[- N]" in my code.

This is the portion of my indicator that plots a cyclical curve and stop exactly on the last bar, starting from the beginning that I've setted.
"ciclo_f" is a propietary function that calculates the line of the indicator.

Code: Select all


ciclo = ciclo_f(Lunghezza, Num.Cicli,StartTime, StartMonth, StartDay, StartYear, Tendenza, Forza);


If Started then begin
Plot1(ciclo, "ciclo");
end else begin
NOplot(ciclo);
end;
If I modify

Code: Select all

Plot1[-N](ciclo, "Ciclo");
I get a simple forward displace (not what I'd like to obtain).

If I modify the code with

Code: Select all

Plot1(ciclo[-N], "Ciclo")
Multicharts give me back an error study:
"Trying to access at data to future. Bars reference value: -N."

So, Now sorry for my misunderstanding, but I don't know where I could modify the code.

Image

Re: Powerlanguage and projection in the future

Posted: 27 Mar 2011
by SP
You need to put your calculated and your projected value into one array and the forward it as one plot.

I.e. if you want a history of 400 bars and a projection of 100 bars then put it into one array.

Code: Select all


vars: x1(0),x2(0),x3(0);
Array: CycleValue [500] (0);

// Replace Close with your ciclo
// History
for x1= 400 downto 0
begin
CycleValue [x1] = Close [400-x1];
end;

// Projected values
for x2= 401 to 500
begin
CycleValue [x2] = Close [0]+Close [0]*Random(.005);
end;


for x3 = 0 to 500 begin
plot1 [400-x3](CycleValue [x3] ," 1" ) ;

end;