Using Custom Formula within a Custom Formula

Hi,

I have created some custom formula(s), say $x_0, $x_1, $x_2. Is it possible to use these custom formulae in another custom formula?

Say, I want to do a sma of the custom formulea

New custom Formula $x_sma
== ($x_0 + $x_1 +$x_2)/3

I get an error "ERROR: Error near ‘$x_0’: Invalid command ‘$x_0’

Once again thanks in advance for you help.


StockCharts Technical Rank (SCTR).pdf (635 KB)

It is not possible to nest custom formulas inside custom formulas. What are you trying to do? Maybe I can help.

Steve

Steve,

What I am trying to do is to find out the 9 day ema for PPO. So, since PPO is not available as a function on P123, I created custom formula for

PPO_0 = ((ema(9,0)-ema(26,0))/ema(26,0))*100
PPO_1 = ((ema(9,1)-ema(26,1))/ema(26,1))*100
PPO_2 = ((ema(9,2)-ema(26,2))/ema(26,2))*100

$PPO_9

Next I created another custom formula $PPO_EMA_9 and was trying something like this

= ($PPO_1 + PPO_2 +… $PPO_9)/9 [I know this is sma, I was just trying quick and dirty to see if that works]

but it gives an error as custom formulae cannot be used in another custom formula.

Big Picture: I am trying to implement Stock Charts Techincal Rank (SCTR) for, say sp1500 and one of the things that SCTR uses is 3-day slope of PPO-Histogram. I have attached to write up, if you care. Once again any help is appreciated


StockCharts Technical Rank (SCTR).pdf (635 KB)

You can’t use a custom formula within a custom formula, but there is an alternative. You can use the SetVar functionality to define what is, in essence, a custom formula within a screen.

So you might do this:

SetVar (@PPO_0, ((ema(26,0)/ema(9,0))/ema(26,0))*100)
SetVar (@PPO_1, ((ema(26,1)/ema(9,1))/ema(26,1))*100)
SetVar (@PPO_2, ((ema(26,2)/ema(9,2))/ema(26,2))*100)
. . .
SetVar(@PPO_9, . . . .

SetVar(@PPO_EMA_9, @PPO_0 + @PPO_1 + @PPO_2 + . . . + @PPO_9)/9)

Then, you can do whatever you want with @PPO_EMA_9

Some users don’t like the fact that you need to do this within a screen, rather than a stored variable. That’s unfortunate. It’s actually a very powerful function that can d a lot – a a heck of a lot.

Thanks Marc,

What if I want to use @PPO_EMA_9 in a rank? (That is my intent)
And while I have you, let me ask, can we implement a simple PPO function in P123.

This is what I had in mind (from one of my other posts)

I was thinking something like PPO(small,large,offset) would be useful to have in P123.
So $PPO_2 (=((ema(9,2)-ema(26,2))/ema(26,2))*100) would be like (new function) PPO(9,26,2).

I really wish that P123 allowed users to nest custom formulae, and I can’t see why its so hard to implement.

setvar isn’t available through ranks.

I’ll have to defer to Marco on the rationale re: nesting.

As to simply adding a PPO function, technical analysis is not really my wheelhouse. But if it’s a helpful concept, we should be able to add it. Can you point me to something where i could study up? (The pdf to which you linked seems to use PPO as part of a larger model.)

Marc,

I think that having a nesting (or using the custom formula in another custom formula) would be a good add and so would be PPO.
Please find the PPO writeup attached with this post.


Percentage Price Oscillator - StockCharts.pdf (508 KB)

Looks interesting. I’ll discuss with Marco.

I guess, that marco does not allow nesting, because it would use up too much computing resources.
Nesting can get very complex to compute, especially if it gets recursive and ends up in an endless loop :slight_smile: