StockFetcher Forums · General Discussion · Help with debugger / code | << 1 2 >>Post Follow-up |
lorypanna 19 posts msg #160383 - Ignore lorypanna modified |
6/23/2023 2:58:16 AM Hi Just a beginner here. Just for information, I'm using the advanced/full version of StockFetcher. I think that it's required for executing the filter below. I'm trying to find stocks with 'converging' values of GMMA EMAs (references in the filter below). The filter below does this: 1. Assigns short-term EMAs to variables 2. Calculates the min and max of all short-term EMAs 3. / 4. Repeats steps 1 and 2 for long-term EMAs 5. Calculates the min and max of all EMAs (MinAllEMAs and MaxAllEMAs) 6. Calculates a value that should describe how much all these EMAs are converging: the general formula is EMAMinMaxRatio = (MaxAllEMAs - MinAllEMAs) / {MinAllEMAs + [(MaxAllEMAs - MinAllEMAs) / 2] NOTE: below you see a variation of this formula, just because I was trying different variations of the same formula, but none of them works ... The problem is that variable EMAMinMaxRatio is not showing in results. The debugger shows a triangle with an exclamation mark near the following commands but the result of the first two is showed in the results and it seems correct: set {EMAMinMaxRatioTmp1, MinAllEMA / SumMaxMinAllEMA} set {EMAMinMaxRatioTmp2, MaxAllEMA / SumMaxMinAllEMA} set {EMAMinMaxRatio, EMAMinMaxRatioTmp2 - EMAMinMaxRatioTmp1} I tried many variations of the formula but none of them worked. Maybe the filter is too complex or maybe there's a limit on the use of "nested-variables". Any help appreciated. If someone knows better ways (more efficient, maybe) to code the min/max sections, help will be appreciated too. Moreover, if someone knows a different way to obtain the same result (identify stocks with converging GMMA EMAs), thanks for sharing. Thanks in advance. Have a nice day. Cheers from Italy |
Mactheriverrat 3,157 posts msg #160384 - Ignore Mactheriverrat |
6/23/2023 9:17:22 PM Well Welcome to Stockfetcher. There a lot of good poster's here still . The bear market of 2022 mid 2023 has slowed SF down some but there still here. |
eronnenberg 5 posts msg #160385 - Ignore eronnenberg modified |
6/23/2023 11:11:35 PM Your script seems to be testing the limits of the calculation engine, or maybe it's just timing it out. The main issue is the unnecessary calculations. This is essentially a MA Wave filter. You're looking for the compression and then expansion of two waves. So you really only need to know the high and low of the two waves; ema3 and ema15 for the fast wave and ema30 and ema60 for the slow wave. Also, having a variable reference another variable that is just a built-in variable seems to hang up things. This should fix what you're looking to do. I just marked out a lot of the extra lines. Also, having long variable names can start causing issues if you have too many. Also, using dow 30 for testing helps load times for faster results. Or russell 1000 if you need more hits. |
eronnenberg 5 posts msg #160386 - Ignore eronnenberg |
6/23/2023 11:39:28 PM Now, to get what you're actually looking to do. I think that you're over thinking it. You're looking for that compression of the faster wave and then the expansion to confirm the signal. So you're really only looking for an MA Cross event. And that'd be ema(3) crossing ema(15) for the fast wave and ema(30) crossing ema(60) for the slow wave. "fastwave" and "slowwave" are just the EMA values added together into their respective waves. It's just a way to see what the wave as a whole is doing. The "signal_fastwave" will be active if the line above what it was the day before. You can use this to see it compressing if it was in a down trend and start expanding after the MA Cross. And vice versa for "signal_slowwave". "wave" is just the fastwave minus the shortwave. It'll show when the fastwave crossed above the slow wave with the 0 line. "signal_wave" is the same as the other signals. However, it's also a decent pivot point indicator. Someone better at this than me could probably come up with a better visual for showing the compression and expansions. But this seems to work. |
lorypanna 19 posts msg #160387 - Ignore lorypanna |
6/24/2023 4:52:29 AM Hi Thanks for the welcome, and thanks eronnenberg for the detailed answers and the code. I know that for sure I'm making useless and probably absurd things, but is the price I have to pay as a beginner with limited time. Thanks for spending time to explain me what I could do better, I really appreciate that. I'll provide a better reply after I have studied your code. But for sure I thank you now because just looking your code I saw a lot of commands / filters I was not aware of. Have a nice weekend. lp |
lorypanna 19 posts msg #160388 - Ignore lorypanna |
6/25/2023 11:39:03 AM Hi eronnenberg, hi everybody Very interesting the changes you made, in the first reply, to my version of the filter: - Simplify the calculation of the variable I was thinking to use as an indicator of compression of the 2 waves (but then I saw your second post ...) - Avoid to assign built-in variables to other variables. I did that because I used them more than once in my filter, and so I thought it was not efficient to ask the system to recalculate them more than once Far more interesting for me the second version of the filter, thanks for this totally new version. It helps me understand how much SF is powerful and gives me an idea about the use of 'flags' (0 / 1 variables). It also shows me how to filter on indexes, I didn't know it was possible (now I found the following help topic: How can I screen for stocks within a specific index? - https://www.stockfetcher.com/help/How-can-I-screen-for-stocks-within-a-specific-index/100337). But most of all it helps to understand what kind of strategies can be used and how to backtest them. One question about this version: you use many commands similar to this one: 'set{slowwave_1, ema(30) + draw ema(35)}'. What the 'draw' command is useful for? I see that the command passes the debugger; if I remove it, it seemes to me that no changes happen ... Thanks again and have a nice sunday. Cheers from Turin, Italy. lp |
eronnenberg 5 posts msg #160389 - Ignore eronnenberg |
6/25/2023 12:39:39 PM "set{slowwave_1, ema(30) + draw ema(35)}'. What the 'draw' command is useful for? " Oh, that was just a mistake on my part. I copy/paste a lot of my commands together, especially if it's similar commands for different variables. The SF scripting seems to be clever enough to ignore commands like that. |
nibor100 1,045 posts msg #160390 - Ignore nibor100 |
6/26/2023 10:50:02 AM @LP, Here is a filter I wrote from a prior Guppy thread "Guppy Investigations". Searching on Guppy and/or GMMA might find other related filter info. Ed S. Here's a trial short filter version of the Guppy MMA's, all aligned, and sorted by those with least separation (short term group is just coming thru long term group, with both groups aligned). Just click on the diff% column to reverse the sort and see the stocks having the greatest separation between the 2 aligned groups. (alignment in this case means the EMAs are stacked from shortest to longest in descending numerical order) Submit |
lorypanna 19 posts msg #160391 - Ignore lorypanna modified |
6/26/2023 1:55:23 PM Hi @nibor100 Thanks for your post and code. I found the post and I will read it with much interest. I'm just a begineer, at present interested in the powerful features of StockFetcher and in reading the interesting posts in the forums. I still have to find my way in trading ... We'll see. Have a nice evening. Cheers from Italy PS: very useful to read your and other users' code. I didn't know it was possible to concatenate many tests on the same line! Thanks |
nibor100 1,045 posts msg #160392 - Ignore nibor100 |
6/26/2023 3:27:17 PM @LP, Your filter that you posted first in this thread had one too many nested levels of set variables so I did a slight modification, without changing any of your logic/calcs, to remove a nested level. Essentially I removed all of your EMA variables and replaced them in your calc statements with the actual EMA(#) calc built into SF, as I've found over the years that SF built in indicators don't seem to count as a level of nesting. Your "add column EMAMinMaxRatio" now works as you intended.... Ed S. |
StockFetcher Forums · General Discussion · Help with debugger / code | << 1 2 >>Post Follow-up |
Copyright 2022 - Vestyl Software L.L.C.•Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data
Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus