Current location | Thread information | |
![]() ![]() ![]() ![]() ![]() ![]() |
Last Activity 10/5/2024 12:51 AM 13 replies, 8720 viewings |
|
|
Printer friendly version |
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
Hi, For years I have adapted zScore and zScoreMA into my Trading. Quite successfully. its very adaptable to all sorts of other indicators. Since the zScoreMA in a pane, as you can see in attachment, more or less moves with price (depending on the parameters of course).. I have been trying to figure out how to Code this so it can become an indicator used in the chart and NOT the pane... As I have additional motivations, creating a zScoreMA Bands..which I should be able to do.. What I can't do, the most important part is try and find a way to calculate this so it Plots in the chart... Any suggestions? If this is even possible?? Thanks, Marc Traditional zScore ----- #Indicator '********************************************************************** '* Z-Score Indicator '* by Jeremy Williams '* February 21,2006 '* '* Adapted from Technical Analysis of Stocks and Commodities '* February 2003 '* '* Summary: '* '* This indicator measures the normalized distance from the '* N period Moving Average using the statistical formula for Z-value. '* For more information see "Z-Score Indicator" in the '* February 2003 edition of Technical Analysis of Stocks and '* Commodities. '* '* Parameters: '* '* N= Specifies the number of Periods used for the Average and '* Standard Deviation calculations used to determine the '* Z-Score. '* '******************************************************************** #Indicator #Param "N",20 Dim myAverage As Single Dim mySD As Single Dim Value As Single Dim OutValue As Single ' Value statement can be changed to other data series. For example, ' to calculate the Z-Score Indicator of the RSI use: ' Value = RSI(Periods) Value = C myAverage = Average(Value,N) ' Calculate the Average and Standard Deviation mySD = STD(Value,N) OutValue = Value - myAverage ' Calculate the Z-Score using the formula: OutValue = OutValue / mySD ' Z = ( Value - Average ) / Standard Deviation If Bar < N then ' At Initialization set OutValue to 0 until OutValue = 0 ' Standard Deviation is not zero. End If Plot("Z-Score",OutValue) ' Plot the Z-score and the 1-Std. Dev. Band PlotLabel(-1) PlotLabel(1) Return OutValue ' Return the Z-value A rather simple, easy Moving Average of the zScore --- #Indicator #Param "periods",3 Dim ZS As Single Dim zsMA As Single zs = zscore(periods) zsMA = SMA(zs,periods) plot("zsMA", zsMA) return zsMA Also, a while back I think it was Mel who coded this one for me.. Another MA of zS. #Indicator #param "Zlength", 4 #param "maPeriod",6 #param "buylevel",-1.6 #param "shortLevel", 1.6 dim zs, theMA as single if bar>(Zlength+maPeriod) then zs = zScoreInd(Zlength,buyLevel,shortLevel) theMA = sma(zs,maPeriod) plot("zMA",theMA) plot("buy",buyLevel,black) plot("sell",shortLevel,black) end if Return theMA ' Return the value calculated by the indicator [Edited by julesrulesny on 11/24/2014 11:40 AM] | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Your OutValue formula is normalized - division by SD does that. The numeric value is therefore not applicable directly to the price pane. You could I suppose modify the calculation somehow but I don't know what you'd want. You must use "plotprice" if you want a value to plot on the price pane. But the scaling is set by the price itself. | ||
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
Thanks for the prompt response. Ok, I do understand what your saying -- But where would you recommend I start? Since the numeric value as you mentioned doesn't make it applicable to the price pane -- Could this then influence zScoreMA or its inability to plot in the chart itself? (since the zScoreMA is strictly an average of the zScore and nothing else... so obviously one greatly effects the outcome of the other). Basically, I don't think it would be much of a problem to modify the calculations... So, we have the original zScore. its very whippy, fast movements and actions. Years ago I just smoothed out it with a very rudimentary Moving Average... and its flawless B/C its so simple, yet adaptive...(IMO of course). Due to its versatility including Volatility, price action in one -- I'm looking to apply the zScoreMA in a chart just like you would use a SMA or EMA ... and maybe use 2 for crossovers and such.. I can do all this in a pane.. I just can't get it in a chart. [Edited by julesrulesny on 11/24/2014 2:41 PM] | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
If you can state simply, in a few words, what you want to plot, I'll try to help. I need more detail than generalizations. | ||
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
Hi Jim, Thanks for that offer -- I have hard time explaining myself at times.. So I'll def do my best. Especially if this is more complicated to do than I initially realized. Ok, if you can see in this zScore Pane -- Noted at "A".. Is the zScoreMA in the pane... I would like to apply it to my chart so it looks like the MA at point "B".. ![]() As in zScore Chart image --- this is what happens when I apply the zScoreMA to my chart by moving it out of the pane.. ![]() I know that due to calculations, some indicators just wont work in the "chart" itself.. and only for use in an Indicator Pane.. However, I believe it can be done .. **for example, someone created "RSI Bands" out of RSI, which typically itself is only used in a pane.. So, basically I just did not know if I can change the calculations, or use a different Return Value, or Plot Price Value, etc.... So that the zScoreMA indicator can follow the Price more closely in the chart.. As opposed to this image of it being up and down all over the place when I moved it into the chart... (as you can see in the first image... when its in the pane, its relatively close to the actual movement of price trending up, down, sideways (when using the proper parameters of course.. But you can see the peaks and valley's, etc are all very close).. I hope this helps. Just looking for a lil direction and hopefully I can figure out how to do it. Always appreciate it Jim. Thank you, Marc [Edited by julesrulesny on 11/24/2014 4:14 PM] | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Sorry - I'll have to pass on this one. I don't follow what you're asking for. I also don't know how the RSI could be used to create bands "around" price in any useful fashion that would actually represent the RSI on the price scale. | ||
^ Top | |||
Mel![]() Veteran ![]() ![]() ![]() Posts: 235 Joined: 3/18/2006 ![]() |
I'm with Jim. If you want the equivalent z-score on the price chart, use Bollinger Bands, with the SMA period at 4 or 5, not 20. The z-score is measuring price stretch from a short SMA in standard deviations, not price, and can't be meaningfully be plotted on a price chart. RSI is a momentum based measure of cycle phase, ideally a sine wave going from 1 to -1, but transformed to 0 t0 1 most of the time. Has no value meaningful on a price chart. It would help to have a better idea of what you are trying to accomplish. Mel [Edited by Mel on 11/25/2014 7:19 AM] | ||
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
This is the RSI Bands by Jeremy Williams. There are some other variations of it as well. It is not perse "Bands or Envelopes" around Price. Its just plotted on the chart. That was what I was looking to similarly do. But of course its entirely different. I was just using this as an example of how an indicator measured in the pane, was plotted in the chart...that's all. Jim, Mel, I think you answered that then.. I guess it can't be done. But I also do realize I am still failing to explain myself. I am sorry guys, this is very difficult for me to do sometimes. I've probably edited this 20 times trying to word it right. I'll try again on what exactly though this time I want, if you can bare with me ----- Like with any Standard score in Statistics, its the deviations above or below the mean - like with Bollinger. And zscore just shows the distance price is from these bands. (I want to get an average of the Deviations.. And how many times its deviating and how far its been, and how far it would have to go to reach a point of breakout or trend reversal.) So for example - 10 days, how many times did price touch the Upper/Lower bands deviate and whats the value/average? Did price touch the bands 4 times, 50, 70 times, etc? How many times is it deviating from the mean? How far did it have to go? And how far away does it have to go to reach the Standard Deviation point/bands.....Also, when not touching the upper/lower bands - What's the difference, or how far is it between price and the Upper/Lower band? And, whats the average? And can this be shown on the chart and not in a pane? Just another way of saying it ---- If I am looking at lets say a 60min. Chart. over the course of 100 days, in theory, price will deviate from the mean ... and we will see this in BollingerBands visually in a chart (and shown how far on zScore)... But we do NOT see how many times it touches,(unless we count), nor an average of how many times it touches, or does not touch.. NOR can we get an average of how far price has deviated? And how far price is current AWAY from a StdDev of lets say 2.. Again, if looking over 100 days, periods, etc.. And you have Bollinger Set to "default" paramaters ... You may see the Open, High, Low OR the Close sometimes touching the upper or lower bands as well as NOT touching it.. I wanna know WHEN price touched it and how often. When not touching it, and how far away is it when not touching... (as well as how far did it have to go to touch it - which is zScore). Maybe it would be like a "moving average" of the Upper and Lower Bollinger Bands and the middle band is the average of how far it has been, on average, from the average price. (Perhaps with another line plotted showing how many times its touching or how many times its NOT touching). ***By doing this, you can get an idea of how strong the Forex Pair is CURRENTLY in relation to previous history based on how many times it can trend thru or breakout upper and lower bands. (ESPECIALLY when used with a correlating pair, or Oil, Gold and/or interest rates...) By smoothing this out, and seeing the distance it travels from its mean, breaking thru the "average" of the upper/lower StdDeviated bands, COMBINED with my zScoreMA - I am hoping tests will conclude this as a workable theory. If its constantly trending or barely breaking out the upper or lower bands, its losing strength.. the longer this happens, the greater the chance of some reversal. Yes we can see this already, but the more times it hits, or the less times it does not hit -- I wanna know the average of this to see how Far it will have to "theoretically" go to START trending.. its an "early warning system" if you will.. if we just counted the distance, counted how many times it does hit the upper or lower bands, as well as counting how many times it does NOT hit.. it will be choppy.. An average smooths this out making it more reliable.. So, the smaller and smaller the average gets b/w Price from the mean, and an increase in average on how many times its hitting(or not hitting) these bands -- its the calm before the storm if you will ..(at least that's my theory and math behind this) zScore itself is choppy if you will. Smoothing it out fixes this and has given me an excellent indicator to use that's versatile. So even tho my zScoreMA is a smoothed out version of how far price has deviated --- in essence that is what a zScoreMovingAverage is.. its just smoothing out the current distance. So sorry... B/c I see I've repeated myself a few times.. So now I am just going in circles. But hope this time I fully explained myself. Is this still sound confusing? Anyways, thanks for trying and reading my post. Marc [Edited by julesrulesny on 11/25/2014 6:45 PM] ![]() ![]() ![]() | ||
^ Top | |||
Mel![]() Veteran ![]() ![]() ![]() Posts: 235 Joined: 3/18/2006 ![]() |
Ok, from all that I infer that you are looking for a way to catch the beginning of a trend, in FX charts. I suggest the following: 1) Use the Ehlers Quotient Transform to detect trend start. 2) Use the Ehlers Roofing Filter Indicator to detect Trend start, by tuning it to the cycle whose upswing is the one you think of as the trend. A trend is the slope of the trend cycle. I have attached the code that does this. Included is an FX version of the Roofing Filter Indicator. It calls a getFXCycle routine to get the wavelength of one of three strong cycles in the FX symbol. The code I am sending has the wavelengths for 240 minute bars. Since FX cycles are strong and stay stable for long periods of time, I use the Spectrum indicator from the ACT module to figure out the wavelengths for the symbols and time frames I am interested in, and put them into getCycle. Then, when you change symbols, you instantly are tuned to the correct wavelength, without having to run time-consuming Fourier Analysis calculations. You can modify the getCycle routine for your symbols and time frame. The only other suggestion I have is to plot the Defended Price Lines using the Relative volume (using adjusted volume) and Freedom of Movement indicators. You will not break out of those little consolidations that are on a DPL until the underlying supply or demand is exhausted. You need to know if you are on one. Those DPLs above and below you are the next likely places for a pause or reversal, so they help you decide if you want the trade at all. Mel ![]() | ||
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
Hi Mel, Thank you. Yes, catching an early trend or breakout is exactly what I want. And Bollinger, zS, with a MovAvg seems to do the trick but its choppy. So thats where I wanted to see the narrowing of space in Bollinger before AND after a trend, or breakout.. If you see in Bollinger how the bands widen away from price and that as it trends, the upper or lower bands are touching price.. When the trend loses steam, zScore goes down(or up) and then we see Gaps between price and the upper or lower bands.. so I am trying to capture that Gap before/after the trend, or breakout.. As well as counting the times it touches. Before I get into ACT/QT ---- Do you think this is still possible to do? As, perhaps this is a simpler computation for OT and wouldn't require so many bars as opposed to using QT or ACT?? I am familiar with Ehlers QT. Many Thanks for this code! And I can see how ACT and QT can go hand in hand. However, I returned ACT. It wasn't what I expected with what I know of Digital Signal Processing, or Fourier Transforms and uses in Trading, etc. John Ehlers seems to be the only one who came close.. I do know, however, its very difficult to apply DSP to a Trading Platform. With mixed results. But, on a quant level can be successful. That is why I returned ACT. I did not think ACT is powerful enough to run these transforms b/c we need such large data sets --- Does this sound correct, or no? Perhaps by loading more bars, would be more successful. Or, perhaps I am missing something? I do know this area to be complicated.. And you have PEEKED my curiosity with this Quotient Transform. Its using FFT to compute time series analysis based on the "frequencies" of these indicators, price, etc. And that is where QT can be great for those long standing trends - as choppy charts, this may not be so useful -- would you agree? Signal processing at my first understanding was not about Cycles. Cycles can be misinterpretted as having predictive value - DSP, or Transforms do not.. Other than using previous history to formulate potential predictability - Like ANY indicator! How then, do you find the Spectrum indicator to work with Ehler's QT? As since I now returned ACT, I don't see how the two can be used together by applying the wavelengths into "GetCycle"? But, it sounds like a brilliant adaptation of ACT. What would you suggest I use if I now no longer have ACT? I was not impressed with ACT at all. It just did not capture what my understanding of using Fourier, Fisher, or DSP in trading. Perhaps Ehler may be the only one who's successfully adapted the use of transforms? | ||
^ Top | |||
Mel![]() Veteran ![]() ![]() ![]() Posts: 235 Joined: 3/18/2006 ![]() |
My view of the market is that all price motion, except for new event caused price impulses, is cyclic. My further view is that only two indicators are in practice, predictive: cycles, since they are relatively stable and thus their contribution to price change can be projected into the future, and Defended Price Lines, since they are long term stable and show you where on the chart things are likely to happen, due to hidden supply and demand. To trade price swings, you trade the dominant cycle (that with the greatest contribution to price movement in the wavelength range that gives you the amount of action you seek. With indicators that tune to this cycle by themselves, you trade hit or miss. Without indicators that portray the cycle clearly (get rid of noise and the influence of longer wavelengths) you get false signals or lose track of phase. The roofing filter indicator I gave you does this well. But you need to tune its passband to the right wavelength. The Spectrum allows you to do this, as do the focused oscillators in ACT 2.0. Using the BB approach means you are looking for a volatility squeeze, supposedly the prelude to a breakout. There are versions of the squeeze indicator published in the forum. For me, a breakout only really occurs when the pool of supply or demand is completely absorbed at a defended price consolidation. Otherwise it may be a false breakout caused by a news event (could also be real, depending on content of the news) , or simply a saunter-out created when cycles that temporarily canceled each other out unwind and price motion continues at a modest pace. Only ACT 2, Ehlers indicators, and Hurst offer meaningful ways to trade the cyclic movement of all charts. They are way ahead of whatever is in second place. Mel | ||
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
Hello Mel, Thank you for your time and helping me with this -- I came to this thread looking to do one thing, and its turned into something else. Currently I am having some issues with my OT/VT as both do not work -- which I am working to resolve..(different thread). Which I also realize I often make things more complicated than they really are. But your posts on this - has given me something to consider and is right up my alley. I never found that use for ACT. I even suspected it had nothing to do with the use of Digital Signal Processing or any Transforms for that matter.. But, now that I understand how you have used that Spectrum Indicator and Wavelengths, my opinion changed --- Just due to my initial lack of understanding.. You sound like a quant. Your knowledge is quite prolific. And I am impressed with your terminology. Its funny how you referenced the Squeeze b/c long ago I traded the Squeeze. Simple and effective. So a lot of my ideas come from that. And, honestly I didn't even realize how much this theory of mine was related to that Carter Sqeeze. funny how you pointed that out and I didn't even realize I was doing it. But, I was hoping to filter out those False signals -- perhaps by getting an average of how many times price deviates too and from the Standard Deviation on Bollinger .. And how far -- Like, if there is some ratio in there that would signal a false breakout. of course nothing is perfect, but was looking to increase my chances! But my ability to translate the way you did in that Omnilanguage you attached for me using Ehlers QT, GetCycle, etc.. is very impressive Mel. I already downloaded the TASC articles from earlier in the year .. And Tom Helget did attempt a translation as well. Didn't John Ehlers write some papers on this?? Rocket Science Trading? Or, something like that --- B/c now I feel I have to read all of this in order to successfully adapt this method. obviously you find it successful - Have you found use for it in Automation? Like OmniPilot? because it sounds to me by using that Spectrum indicator, it can't be Automated? Not even Mechanical? Additional questions: Regarding the use of the secant and cosecant of a 45degree angle. 1.414? **I am just curious then -- that use of 1.414 being a Fibonacci ratio.. Can other ratios be used like 1.618? I wonder how this line of code is in use for the indicators you attached?? ... Maybe its nothing .. But, I focused on that line and am just curious why its in there? Perhaps a "midpoint" in the chart?? OR -- Is it a mid point in price? I think of Gann fan lines when I see that... Which leads me to ask if GANN then, can be used in conjuction with this on a Geometric level? I apologize for my questions.. I am just trying to understand all of this. As for HURST - yes, for all the plugins Nirvana offers, this gives the BEST signals out of the box. Nothing comes close. The indicators fall short in my opinion, but the signals are amazing. to this day I still have HCT enabled in all my profiles. And there is nothing like it in the industry. Nothing even close. Thank you so much for taking the time and responding. Its much appreciated. You may not recall, but you've helped me quite a lot over the years always giving me different codes, and writing codes for me. Thank you. Jules [Edited by julesrulesny on 11/28/2014 12:49 PM] | ||
^ Top | |||
Mel![]() Veteran ![]() ![]() ![]() Posts: 235 Joined: 3/18/2006 ![]() |
You can call the Spectrum indicator from OL, and it will return the dominant cycle wavelength in the bandpass you specify. Automation is possible. 1.414 is the square root of 2. Nothing to do with Fib numbers. It is part of Ehlers calculation of a modified three pole Butterworth Filter (DSP stuff). Read "Cycle Analytics for Traders" by John Ehlers, his newest and most readable book. ACT really is all DSP stuff. Mel Mel | ||
^ Top | |||
julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() |
Oh ok. Thank you. I just had recognized it, thought it was the 45 degree angle.. thus assuming it was a Fib. Ratio... I'm actually surprised I didn't know that -- much to learn.. And, now I know where to look (ie, butterworth filter) regarding this. thanks. Apparently what I did understand was a bit off. Rather, what I 'thought' I understood was insufficient. Since I recall DSP, Fourier, etc from Math courses. And, when I didn't see a change in signals, I concluded it was insignificant altogether. My mistake. I will check out "Cycle Analytics for Traders" ... Thank you. |
|
|
Legend | Action | Notification | |||
Administrator
Forum Moderator |
Registered User
Unregistered User |
![]() |
Toggle e-mail notification |