Syntax / Variable Question - Cliff notes below

Login or Register

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

11 posts / 0 new
Last post
whatstop
Last seen: 1 year 4 months ago
Joined: 07/19/2018 - 03:43
Syntax / Variable Question - Cliff notes below

Hi,

I've been working on this for several hours and am running into a wall.

Using the ZZO token, I have created a signal that is TRUE when the Delta Percent since last up pivot is greater than a user specified variable.

(ZZO_delta / ZZO_vol) * 100 > C#3

I am trying to measure how far price travels before taking out the swing low of that pivot. As such, using Signal Statistics to capture Bars Since Signal is not sufficient, since the signal does not occur at the low preceding the up pivot.

I created a separate indicator using SSTAT to determine the Bars Since Last Signal, and another indicator to determine the Bars Since Last Pivot (only recording this value when the signal is true).

What I would like to do and am having trouble with, is to sum those two values (Bars Since Last Pivot on which the signal occurred) and Bars Since Last signal, in order to have a variable with which I can examine whether the lowest low of X bars was beneath the low of that pivot (ending the "move"). Then I can view the Max change since the low of the pivot on which the signal occurred.

I am uncertain how to do this. I attempted to store those values as C# variables, but it seems to only hold the current value and not retroactively store that value bar by bar.

The chart is below. Would appreciate some suggestions for how to accomplish this. Thanks

https://www.linnsoft.com/charts/study-delta-rotations-es

0
whatstop
Last seen: 1 year 4 months ago
Joined: 07/19/2018 - 03:43
To phrase differently:

To phrase differently:

How would I go about storing variables in IRT and utilizing those variables for calculations? It seems the option to "Store current value as C/V variable" only holds the current value and does not historically plot it, and using the SET function I always get a response that it should be boolean.

Here is what I am trying to accomplish, laid out in a bit of psuedocode:

def Indicator1
def Indicator2
def Signal1
def Signal2

If Signal1 then:

x = indicator1
Signal2 = true

end;

While Signal2:

x += 1
Signal2 = Signal2(x)

end;

I realize if I am using Bars Since Signal I do not need to initialize a counter, but I need a way to add the initial value when the signal occurs (Bars since pivot) to a variable that updates with Bars Since Signal, so that I can go back and record the highest high and lowest low of X bars (Bars Since Signal + Bars Since Pivot (On Signal Bar)

whatstop
Last seen: 1 year 4 months ago
Joined: 07/19/2018 - 03:43
Any thoughts on this?

Any thoughts on this?

cpayne
Last seen: 1 year 9 months ago
Joined: 03/30/2009 - 00:00
So just to make sure I

So just to make sure I understand what you're looking for.  See image below...

So you want to know the increase in price....from the high of the signal bar...to the highest price achieved....before returning the the price at the low pivot before the signal bar?  Is that correct?

whatstop
Last seen: 1 year 4 months ago
Joined: 07/19/2018 - 03:43
Yes. Not necessarily the high

Yes. Not necessarily the high of the signal bar, but when the signal triggers, and then when the low pivot is breached. That is the concept though.

I can set it up to reference the pivot of the signal, but that gets thrown off if another signal occurs.

cpayne
Last seen: 1 year 9 months ago
Joined: 03/30/2009 - 00:00
Max Move Before Retrace

So I've added this option to ZZO for next release.

On every pivot, it will give you the max move (in same direction) that was made (from the high of leg) before it came back and broke the low pivot of that leg.  With that in place, will you have what you need?

whatstop
Last seen: 1 year 4 months ago
Joined: 07/19/2018 - 03:43
That would be helpful. I do

That would be helpful. I do wonder, if it might add more flexibility for other studies and add less footwork to measure the max move from the pivot in question, before a retrace of the pivot in question, rather than max from high before retrace of low?

Eddy_F
Last seen: 3 months 2 weeks ago
Joined: 07/30/2014 - 16:18
Suggested chart

Hello,

Chad, your new ZZO token seems highly interesting, so I would suggest to add it to the ZZO toolbox.

I had the opportunity to chat few months ago with Whatstop, so I know that his request is complicated because of the 2 following points :

1) he wants to get the Highest move reached after a given signal (the accumulated delta percent on a given zig zag upleg) UNTIL the previous Pivot Low (of the original signal leg) is broken – This “exit point”, which needs to be taken into account, as it will influence the value of the MFE Move (Max Favorable Excursion Move), is linked to the price of the “entry point”, so the only way to get that “period” represented inside a custom indicator is to use a Trading System type of indicator as the exit is a P&L type of exit, ie linked to a price related to a given entry point (it is fundamentally a “stop”) – This will also allow us to skip consecutive signals as long as the initial signal is “still alive”

2) the other issue is basically more “technical” and linked to the ZZO token complexity –– Of course, a delta percent measurement (or any other data calculated) on a zigzag up leg is only “confirmed” when the corresponding ZZ up leg is confirmed, ie the minimum down retracement is reached – So any indicator based on ZZO=1 in order to detect a pivot up or down bar (and calculating any statistics) is retrospectively “looking forward” (in order to make sure this is a “confirmed” pivot).
So what I observed (without any surprise) is that using the TSYS token in such an environment (ie with an entry which require a forward looking data) wont produce the expected result (and that’s quite normal as you shouldn t use any forward data in a true backtest)

But if the purpose of the study is to evaluate (after the fact) for statistical purpose only "confirmed" signals (and won’t be run live), then one is entitled to use look forward data
So, after some trial, I found that the good old SSIM token (System Simulator) which is the ancestor of the TSYS token (but which is 20 time less sophisticated) seems to be compatible with the use of forward looking token (such as ZZO for detecting pivot) – Moreover, SSIM has the great advantage to have a very intuitive set up window.. So the chart herebelow is answering to Whatstop statistical study request,

https://www.linnsoft.com/charts/rotation-stat-study-es

1) To make thing easy, as we are going to look forward anyway, I am locating all the study results (o be displayed with paint indicators) at the initial Pivot low bar, prior to the upleg with the right Delta percent using the looking forward FREF token (in order to keep reference to the initial CI syntax)

CI_ENTRY = ((DOWN_PIVOT=1)*FREF(CI,BAR_TIL_PIVOT_HIGH))

With the CI being the delta percent as measured at the pivot high
So the "Entry Signal" to be used in the SSIM defintion is basically CI > V#3

2) Then, I am defining a System simulator token (see attached screenshot) for a Long position with
CI ENTRY SIG as above – I use the Low price (ie the pivot low price)
CI EXIT SIG : I am just closing by default any position at the end of the day session (otherwise, you may only have one Signal considered if you are lucky enough to catch the bottom)
You could in fact here put any kind of Exit Signal (if you don’t want to wait an hypothetical pivot Low break after having catched a market bottom)
STOP LEVEL : is fundamentally Low price less half a tick or so (as we want to break pivot low by at least one tick)
And that’s it – The Blue color band / marker on the first pane is just based on the Signal :
SSIM (status) =1 (ie a Long “position” is ongoing)

And, in order to display the study area on the price chart, I use a ZONE indicator based on “consecutive signal” is true, with the same signal (SSIM / status =1)

3) In order to get the MFE over the period, I am defining first Generic Signals for detecting the entry and exit point of the System Simulator
SSIM entry point (SSIM=1)*(SSIM.1=0) >0
SSIM exit point (SSIM=0)*(SSIM.1=1) >0

Then in order to look forward and get the MFE / Highest High price information (at the entry point) , I am using the following custom indicator

(ENTRY_LONG_SSIM=TRUE)*(FREF(MAX(HI,BARSCE_ENTRY),BARTIL_EXIT)

With
BARSCE ENTRY = Signal STAT token with Bar since last SIG with SIG = SSIM entry point
BARTIL EXIT = Signal STAT token with Bar until next SIG with SIG = SSIM exit point

And in order to get the MFE move (ie the push beyond the first Pivot High price) :

(ENTRY_LONG_SSIM=TRUE)*((FREF(MAX(HI,BARSCE_ENTRY),BARTIL_EXIT)-FIRST_PIV_HIGH_PRICE)/TINC)

adding the FIRST_PIV_HIGH_PRICE = SSTAT token / price at next Signal with Signal = PIVOT HIGH

Notes / Comments :
a) As prev. discussed with Chad, a FMAX token would simplify a lot the above “FREF (MAX(HI,SSTAT_A… ),SSTAT_B) “ type of syntax
Typically a FMAX (expression,n) token would return the maximum of the expression over the coming n bars.
With the FREF (MAX(HI,CI),n) solution, the issue is that the whole “expression” (including the CI) is evaluated at the forward bar, therefore one need to use MAX(HI,BAR_SCE ENTRY) in order to get the right number of bar (looking backwards) at the forward point…
ie with FMAX, we could use the more intuitive syntax FMAX(HI,BARTIL_EXIT)

b) I could have theoretically used the Zone High & Zone Low token in order to get to the MFE, but while the Zone indicator is correctly displayed (which is a huge achievement), these ZONE token values aren’t correct, which is not a big surprise due to all the looking forward & backward activities within the underlying Signals of the SSIM. Anyhow, what is important is that the MFE value are correct with the FREF approach explained above…

c) For the record, I could also have used successfully the TSYS token approach (instead of the SSIM) but obv without any forward data, ie this woiuld require to have as entry bar the first down retracement after an upleg having the right percent Delta… but as the SSIM token worked well, I kept that option…

cpayne
Last seen: 1 year 9 months ago
Joined: 03/30/2009 - 00:00
FMAX, FMIN, FSUM

Eddy,

I haven't had a chance to read through all you wrote, but did see something about FMAX.  I'm not sure exactly when, but FMAX, FMIN, and FSUM have all been available for a while in RTL.

Chad

Eddy_F
Last seen: 3 months 2 weeks ago
Joined: 07/30/2014 - 16:18
Damned, I start to ask for

Damned, I start to ask for tokens... which are already there !!
Getting older every day as indeed FMAX / F MIN / FSUM made it to the RTL token list.. Such look forward approach for statistics will become much easier to formulate..
I just updated the MFE syntax above w FMAX, and it works nicely indeed :-) MFE formula becomes much simpler (even if the whole approach isn t really..)
Need to update 40 or 50 indicators in my db still using that complicated work around...
Thanks a lot for the prompt feedback
Eddy

whatstop
Last seen: 1 year 4 months ago
Joined: 07/19/2018 - 03:43
Eddy, thanks for your help.

Eddy, thanks for your help. Chad, my question has been answered. This framework will accomplish what I am looking for. Thanks