Powerlanguage and projection in the future

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

Powerlanguage and projection in the future

Postby CrazyNasdaq » 08 Sep 2009

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
Attachments
Cyclical Multicharts.png
My indicator using Multicharts
(86.54 KiB) Downloaded 1980 times
Cyclical Metastock1.png
First Snapshot from Metastock
(111.38 KiB) Downloaded 1966 times
Cyclical Metastock2.png
Second snapshot from Metastock
(136.17 KiB) Downloaded 1975 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Powerlanguage and projection in the future

Postby TJ » 23 Mar 2011

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.

jek
Posts: 181
Joined: 24 Dec 2006
Has thanked: 1 time
Been thanked: 2 times

Re: Powerlanguage and projection in the future

Postby jek » 24 Mar 2011

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?

User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

Re: Powerlanguage and projection in the future

Postby CrazyNasdaq » 25 Mar 2011

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.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Powerlanguage and projection in the future

Postby TJ » 25 Mar 2011

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]....

jek
Posts: 181
Joined: 24 Dec 2006
Has thanked: 1 time
Been thanked: 2 times

Re: Powerlanguage and projection in the future

Postby jek » 25 Mar 2011

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.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Powerlanguage and projection in the future

Postby TJ » 25 Mar 2011

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.

jek
Posts: 181
Joined: 24 Dec 2006
Has thanked: 1 time
Been thanked: 2 times

Re: Powerlanguage and projection in the future

Postby jek » 25 Mar 2011

Bingo. Thanks, TJ. I was fooled because the windows that failed had multiple instruments in them and thought that it was the cause.

:)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Powerlanguage and projection in the future

Postby TJ » 25 Mar 2011

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.

User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

Re: Powerlanguage and projection in the future

Postby CrazyNasdaq » 26 Mar 2011

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
Attachments
Ciclo.png
(41.73 KiB) Downloaded 1900 times

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Powerlanguage and projection in the future

Postby SP » 27 Mar 2011

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;


Return to “User Contributed Studies and Indicator Library”