Setting P&F reversal criteria with a V# variable

Login or Register

Please login or register in order to view and post in the Forum.

7 posts / 0 new
Last post
whatstop
Last seen: 1 year 3 months ago
Joined: 07/19/2018 - 03:43
Setting P&F reversal criteria with a V# variable

Is there any way to do this? Thanks

0
whatstop
Last seen: 1 year 3 months ago
Joined: 07/19/2018 - 03:43
Found this post which is

Found this post which is helpful but I need to work on translating to PNF and work around the box size limitation

https://www.linnsoft.com/topic/automate-periodicity-change-symbol-change...

whatstop
Last seen: 1 year 3 months ago
Joined: 07/19/2018 - 03:43
Can't get this to work. Haven

Can't get this to work. Haven't even got around to addressing the PNF size limitations, which I planned to do with conditionals. However, since if then statements don't work, I can't really use calculations on strings. Ignoring that for now..

When I use the syntax "SET(T#1, ".01x%V#9") it sets the appropriate numerical values, but if I append a "p" to the end to specify point & figure, it just displays V#9 as the text variable.

If I add a space, it calculates the V# variable, but the input doesn't work on the chart.

Eddy_F
Last seen: 2 months 2 weeks ago
Joined: 07/30/2014 - 16:18
Tricks for generating T# variables

Hello Whatsapp,
T# are a little bit tricky at first sight, but you can generate pretty much anything, including with a conditional statement -
So there are few ways to achieve what you want -
Here is the easiest syntax (without creating any intermediate extra T# variable) using the simple "aggregation" trick
SET(T#1,"p")&SET(T#1, ".01x%V#9%T#1")
Personally, I have stored once for all in a T# (lets say T#60) all the pnf tick increment (aka SET(T#60,".01x") so that the syntax for creating my own default PNF periodicity (store in T#1) has a generic syntax (Just need to introduce once for all in a QP all the relevant T#60 string and run a simple scan whenever i want to update them)
SET(T#1,"p")&SET(T#1, "%T#60%V#9%T#1")

I am not sure what you wanted to achieve with a conditional statement, but here is an example of what is feasible
lets say i have generated / stored in T#2 my default renko periodicities (input is V#10) for a given instrument
SET(T#2,"Re*")&SET(T#2,"%V#10%T#2")

So now, lets say that i would like to use for some instrument, as default periodicities, the renko one or the PNF one, upon the value of the V#500 variable (that i may change thank to a button)
so the full rules would be
SET(T#1,"p")&SET(T#1, "%T#60%V#9%T#1")&
SET(T#2,"Re*")&SET(T#2,"%V#10%T#2")&
SET(T#1,V#500>0?"%T#2":"%T#1")
aka if V#500 is positive then default periodicity is set to the Renko one, otherwise this is the PNF one..

You could embed different levels of conditional rules inside a SET T# statement if needed, as explained in the IRT 8.9 "whats new" paper (released back in 2007..)

The RTL conditional operator (expression ? a:b) can now be nested to perform SET statements on text variables, e.g. SET(T#22, V#1 > 0 ? "a" : (V#2 > 0 ? "b" : "c")); will set the text variable T#22 to "a" when V#1 > 0, otherwise it will set T#22 to "b" or "c" based on the value of V#2.

(this feature could be added to the T# support page https://www.linnsoft.com/support/text-variables-t-variables)

whatstop
Last seen: 1 year 3 months ago
Joined: 07/19/2018 - 03:43
Eddy,

Eddy,

That was very helpful for overcoming the first hurdle. I suppose what I need to do now is apply logic to determine the box size. I can use an extra variable to store the value if there is not a more straightforward way.

Here is what I want to accomplish.. I am calculating a typical rotation for equities. This could be hundreds of symbols. I want to be able to use a price rather than time based chart (PNF). By doing what you showed me, that is easily accomplished. The problem is, there are some cases when the typical rotation is larger than the maximum PNF size (31). In that case, I need to use a larger box size. I'd like to run a check for the rotation size. So I think I could set the box size by dividing V#9 (the rotation size) by 31, and then rounding up.

E.g.

V#9 represents the rotation size, in pennies, multiplied by 100 (to equal ticks)
V#9 = 75
V#9 / 31 = 2.41

So I would want to increase the box size to .03, and divide the rotation size by 3, for a PNF of .03x25.

I'm fairly sure I could write a bunch of logic and use multiple variables to accomplish this, but I'm wondering what a more efficient way might be in IRT. Something like a loop that evaluates V#9 / 31. And I also need a way to round up any decimal > .00.

I'm going to think about this some more.

Eddy_F
Last seen: 2 months 2 weeks ago
Joined: 07/30/2014 - 16:18
ROU token

Hi,
this should be very easy to automate. In order to perform some rounding, you will need the ROU RTL token
SET(V#1,ROU(V#9,1)) will round V#9 to the nearest unit and store it into V#1
SET(V#1,ROU(V#9,0.1)) will round V#9 to the nearest dime
SET(V#1,ROU(V#9,0.25)) will round V#9 to the nearest 4th.. etc
Cheers
Eddy
(PS : whenever you manipulate V#s, never forget to make sure your V# formats are well defined in the user variable preference settings)

whatstop
Last seen: 1 year 3 months ago
Joined: 07/19/2018 - 03:43
Ok this is what I figured out

Ok this is what I figured out

/*
V#48 = Rotation size express in ticks
V#49 = Rotation multiplier / divisor to adjust box size & height
V#50 = Box size
V#51 = Box height
*/

SET(V#48, 100*V#9)&
SET(V#49, (V#48/31 <= 1 ? 1 : ROU((V#48/31+.5),1)))&
SET(V#50, V#49*.01)&
SET(V#51, V#48/V#49)&

SET(T#1,"p")&SET(T#2,"x")&SET(T#1,"%V#50%T#2%V#51%T#1")