Month: May 2020

Reminder Message (w/ color picker demo)

Reminder Message (with color picker) – ApopheniaPays by ApopheniaPays on

TradingView Script. Free TradingView account required to use. Direct link:

This is a very simple script. It displays a message above the latest price. I coded it because I need a constant reminder to keep me from overtrading.

You can customize several options:
– The message text
– How high above the latest price the message is displayed
– How often it is displayed. 1=display constantly, 2=only show it during every other period, 3=only show it every 3rd new period, etc. So, for example, if you are on the 15 minute chart, and set a frequency of 3, it will show it for the first 15 minutes out of every 45.
– The text size
– How many bars back from the last bar you want to position the text
– Whether it’s displayed above, at, or below the price
– Color and lightness. This can be used as an example of how to add a color selection input to your own scripts.

Note: by positioning using time instead of bar index, it would be possible to move the text ahead (to the right of) the last bar, but I’ve found that this gets complicated because you have to account for the time frame of the graph, so I leave this as an exercise for someone else.

Demonstration of how chart history length affects current EMA values

Demonstration of how history length affects all EMA values by ApopheniaPays on

TradingView Script. Free TradingView account required to use. Direct link:

I saw some discussion of this so I whipped up an example to prove the that effect of history length on EMA values is pronounced, even for bars much further than the EMA length away from the first candle of the chart.

This chart has two 89-bar EMAs of the close: a green one and a red one. However, for the red one, the first 89 bars of the graph are considered to have a close of “0”, which is exactly whatTradingView’s EMA calculation uses for bars before the start of the graph.

This is because unlike other moving averages, which reference the price of previous bars, the EMA references the EMA of previous bars. Therefore, bars closer to the beginning of the chart, where TradingView can’t calculate an EMA because there is no previous EMA and therefore uses 0, will return substantially different values for the EMA () function that the same cart would with more history.

The further a bar is back in history, the less influence it has. However, every single historical bar has some influence on the EMA of every later bar.

To allow you to see this for yourself, this script contains the following inputs which you can change to see the effect:
-EMA period (default 89)
-Number of bars to ignore for EMA2 (default 89)
-decimal precision to show differences in. By making this a large number you can see that, although the effects diminish, history length affects all EMA values for the char.
-label spacing (increase this if you have a long history and run into TV’s 50-label limit)

Range Strategy demo

ApopheniaPays Range Strategy by ApopheniaPays on

TradingView Script. Free TradingView account required to use. Direct link:

A very simple demo, made by request, to allow a user to set simple buy and sell levels and see how profit changes as you mover them.

AP VWWMA/Volume-Adjusted Price lines 5.4.2 shared alpha

AP VWWMA/Volume-Adjusted Price lines 5.4.2 shared alpha by ApopheniaPays on

TradingView Script. Free TradingView account required to use. Direct link:

Initial alpha release, just for you to play with. No warranty, guarantee, support.


This is an alpha of one of my most frequently-used custom indicators, provided without support or guarantees, for anyone to experiment with: the Volume Double-Weighted Moving Average and Volume-Adjusted Price Lines.


Yellow/reddish line: VWWMA. Essentially a VWMA , but built on a WMA rather than an SMA . A very frequent target for brief mean reversions.

Blue line: WMA . If you look at movements of the VWWMA compared to movements of the WMA , it will tell you how much of an effect volume has on current movements. If the VWWMA moves towards the spot price more quickly than the WMA does, it means volume has joined in.

Yellow/red band between the VWWMA and the WMA: turns red for noisy movements, yellow for volume-supported trends. You may notice a correlation between the rate of change of the color band and the rate of change of the distance between the VWWMA and the WMA .

Everything else: Volume-Adjusted Price Lines. These are a an algorithm that shows moving points of control that frequently serve as support/resistance or mean-reversion targets. Just watch for a while. You’ll get it. There are 8 of them, all the same function but with different weighting constants: .5, 1, 1.5, 2, 3, 4, 5, 6. The ones I’ve found to be most informative are given more visual prominence. The values I’ve used are good but not canonical. For instance, I’ve noticed that price will often turn around in “mid-air” right where a VAP with weighting 3.5 would be, even though I didn’t include that as a default value. But the values I’ve included tend to be pretty useful.

I find that the VAPs very often fall into familiar movements (or noticeable lacks of movement) that are pretty consistently predictive of upcoming price changes. They also often coincide with VPVR points of control and other indications of support/resistance .


I use this on BTCUSD , particularly on the 1min chart, but I’ve seen it be useful on the 1hr & 4hr too.

I usually place three of copies of this indicator:

Period 720, length 50, color set red, show up/down trends with colors, rainbow bands based on VAP #4, show WMA /VWWMA band.
VWWMA period 360, comparison length 50, color set dark yellow, don’t show up/down trends with colors, no rainbow bands, don’t show WMA /VWWMA band.
Period 1440, length 50, color set blue, don’t show up/down trends with colors, no rainbow bands, don’t show WMA /VWWMA band.

Then I hide the 360/1440 until I need them. The 720/50 is my main goto for BTC on Coinbase, it’s always on.

I set an alert the 720/50 to let me know when VAPrangeCompression crosses 0.5 up, that will give a good alert when something is up. Sometimes I set that alert on 1440 and 360 as well, but not always. VAPrangeCompression will often go from 0 to 1 before a big move. If you watch it long enough, you’ll start to detect consistent patterns.

Also, sometimes, if I just can’t figure out what’s happening, I’ll set the 360 or 1440 to a comparison length of 25 or 100 to get a different perspective. Shorter length makes the lines more responsive, but i think longer lengths give you a more accurate read on what’s going on. 50 seems to be the best in most cases.

The above settings work on a lot of charts and resolutions, but generally they’re better on exchanges with higher liquidity. Sometimes if they just don’t seem useful, I’ll look at a chart’s history, and adjust them for that chart until they seem to reliably indicate things that have happened, then use those settings going forwards. But mostly I leave the settings alone.


The original intent was to improve upon the VWMA , come up with something that better reflected the “REAL” market value, regardless of where spot price was. The problem with VWMA is their movements in relation to unweighted averages tell you a lot but their absolute position doesn’t actually tell you much. I wanted to use volume to determine an absolute value that the the market “wants” an instrument to be at.

However, mathematically, the general picture is this: roughly, a Volume-Adjusted Price is just an average of two values, the spot price and the previous bar’s Volume-Adjusted Price, weighted by a function of relationship between recent volatility in the VWWMA vs recent volatility in the price by itself over the same period. The less the price volatility has correlated with the VWWMA volatility (hence the greater effect of volume on price), the more the line moves towards the spot price from its previous value.

I really need to get my website going and do a real writeup, but I discussed the nuts & bolts of it a bit in the following threads on twitter:
Calculating the VWWMA:
Calculating a Volume-Adjusted Price line:
A slight correction to the formula for Volume-Adjusted Price lines:
Overview of reading the VAP lines:
Some inconclusive musings on how VAPs move and predict pumps and dumps:

Now, the trick here is, I provide this just as a fun fact, when I was first experimenting with this idea, I made a mistake. And I tested the most promising version of the algorithm for a week or two without realizing a mistake had crept into my weighting formula. And in that time I noticed pretty spectacular leading indication of price action. It was only after I really started to trust that the formula worked that I looked at it again, and realized there was a math mistake in it. So I fixed the mistake… and the indicators stopped working well. So, to this day, the weighting calculation has an intentional mistake in it. I know where the mistake is. Anybody who know anything about this stuff would look at the algorithm and see that I’d done something wrong. I don’t know why it works so well with the mistake. But it works. It’s like I threw a box of junk parts in the air and they accidentally landed in the shape of a working motorcycle. Total serendipity.

AP Risk Management Assistant 20-02-25.01 shared alpha

AP Risk Management Assistant 20-02-25.01 shared alpha by ApopheniaPays on

TradingView Script. Free TradingView account required to use. Direct link: h

Initial alpha release, just for you to play with. No warranty, guarantee, support.


A word about the “regretted sale” features:


This is the level at which you will lose the same amount by having sold and bought back in as if you had simply held without selling. If you buy back at this level after a regretted sale, whenever you sell again, you will make the exact same profit or loss as if you had not made the regret sale. And every dollar below this price that you buy back in, is a dollar more profit you would have made if you had held and sold at that price. So if you now expect the price to go back up, you can get back in the game at this price or lower. Even if it goes back up just a little more than the spot price of your regretted sale, you can get back in at this price and then at least cut your losses by selling higher. Beware though — if you buy back in using this feature and then you sell anywhere below where you originally made the regret sale, you will lose more than you would have by simply not buying back in. Buying back in like this can only be profitable if the spot price goes back up at least to where you made the regret sale, and then, you have the discipline to really sell again at a higher price than that.

For instance, if you are on track to break even on 1.5 WhatsiCoins at spot price $1500, but instead stop out at $1435, and check the ‘I REGRET IT’ box and fill in 1.5 and $1435, it will give you a buyback line at a lower price, say, for example, $1417. If the price drops past $1417, and you buy back in, and it rises again to $1500, you can sell at $1500 and break even overall, exactly as if you hadn’t made the regretted sale. Or if the price drops to $1400 and you buy back in there, and it rises to $1500, you can sell there, and instead of breaking even you’ll make $25.50 profit. ($17/WhatsiCoin * 1.5 coins).

However, if you buy back in at $1417 and it only goes to $1425, and you sell there, you’ve taken on an additional loss of $15 ($1435-$1425 = $10 loss/coin, * 1.5 WhatsiCoins) and you would have done better not to buy back in.

And always remember: when you make a regret buyback, yeah, you’re where you would have been anyway, but, that position is further from profitability. If you make a regret buyback at $20 less than you sold out at, you’re now $20 further from profitability than you were when you sold, no matter what, and good luck with that addtional obstacle. And if you buy back at more expensive, and the price falls to your stop again, you’ve lost even more.

Generally, stop-losses are a good idea. This indicator aims to help you plan them sensibly.

So if you clearly made a bad mistake, and things go just right and dip far enough before a clear and predictable HUGE rebound that you’re sure is coming, this “REGRET IT” feature can get you back in to profit at no cost whatsoever. Or, it can easily cost you even more money, chasing your losses like a clueless newbie. Be careful.

Crossing detector & 2-field date/time entry [tradingview]

ApopheniaPays Crossing detector & 2-field date/time entry by ApopheniaPays on

TradingView Script. Free TradingView account required to use. Direct link:

A demonstration created by request.

You specify a horizontal line by value, start date/time, and end date/time, and choose a data source (bar close is the default) and it will label count how many times that source crosses that line between those dates/times.

“Crossing type”: count only crossing up, crossing down, any cross, or any touch at all. “Any touch” ignores the source you specified in the first input, and triggers if any part of the candle at all is touching the specified value.

BONUS DEMO FEATURE: Enter the start and end dates for your horizontal line as MMDDYY and HHMM (24 hour time).

: Jan 17, 2020 would be 11720 (properly it would be 011720, but Pine inputs delete leading 0s).
: November 17, 2020 would be 110720.
: 8:30 AM would be 0830.
: 8:30 PM would be 2030.

Remember to enter the right time zone.

I believe nobody else has published a 2-input date/time picker on TV, at least the last time I checked they hadn’t, they all make you input M,D,Y,H,M as separate fields. Ugh!

If you use any parts of this code, please credit me. If somehow you happen to make a lot of money using this code, please think about what a fair share would be to pay me for my help, then give that amount to a worthwhile charity.

A little background: In all modesty, I’m not an unintelligent guy. I have a science degree and several decades experience independently designing and programming custom business software. I’m a dedicated empiricist, a systemically-adept professional algorithmic thinker, and no stranger to mastering conceptually difficult things… the kind of guy who throws together a satirical WordPress website, installed and configured entirely by hand on a naked Ubuntu cloud server from scratch without using any installer scripts, over a weekend just for fun.

I’m also an avid lifelong musician who plays a handful of instruments well (I’m told). I have six albums currently in various stages of completion, spanning genres from delta blues to classical to electronic to experimental… no, I’m not exaggerating, that’s the truth… so I’m not, like, a straight-ahead wonk. I see the art in things and understand intuitive approaches. (Programming is more like this than people think, too.) I believe it’s possible to rationally examine mysticism and more subtle phenomena than most pure pragmatists spend time thinking about. I do believe it’s likely that there are more things in heaven and earth, Horatio, than are dreamt of in your philosophy.

I don’t mean to brag. I just wanted to fill in some color and detail on the person everything else you read here comes from. I just feel like if there’s anyone who’s shown they’re likely to be able to get a bead on conceptually difficult, abstruse things, and learn to understand and manipulate complicated systems, it would be me. …This is, assuming there is indeed something to them to be learned, understood, or gotten a bead on.

I started learning to trade in 2017 on the assumption that profitable algorithmic trading strategies are possible and that successful trading is not a game of chance. My primary goal was to codify the decision-making processes of successful trading into an algorithm — essentially the same exact thing I’ve made a successful living doing professionally with business rules for many, many businesses over my career as a developer and consultant — and ultimately use it to generate passive income from the extreme volatility of cryptocurrency.

I very quickly became involved in Reddit (which is a cesspool, by the way) and between working on algorithms, studying and learning to trade, and even a brief stint on the mod team of one of the largest crypto trading subreddits, trading became a full-time job and more.

In the last 3 years I’ve become extremely skilled at TradingView’s Pine scripting language, extremely familiar with the rationales and calculations behind many of the most common indicators, and spent the better part of a thousand hours developing and backtesting both my own strategies and implementations of others’. Since then I’ve whittled a substantial initial trading account down by about 70%… a five-digit loss… and never found a successful strategy, nor ever found a single person, book, or website that could offer any trading advice or knowledge that turned out to be more reliable than flipping a coin.

I’m sparing you a very long rant, but at this point I’m 99.97% certain, based on evidence and careful examination, that trading crypto is purely a game of chance, primarily consisting of elements more closely resembling tarot card reading, astrology, and dice or roulette than any kind of discipline, knowledge, or learnable skill; and, that most “successful traders”, if any really exist, are basically coasting on luck and survivorship bias. The people for whom the exact same knowledge and techniques did not work, who didn’t get lucky, simply didn’t stick around on #CryptoTwitter to keep talking about their experience, so we’re left with a bunch of people who made a lot of money, saying, “Look, we ALL made money, it must because of skill, we couldn’t ALL have gotten lucky.” But the unlucky people just dropped out. 

Every person I’ve talked to, every book or website I’ve read, every video I’ve watched, that tried to teach a “technique” or “strategy”, that technique or strategy was just as likely to lose money, and in at least equal proportion to how much it won… which, which you consider the “house odds” of a market strongly manipulated by whales and the small, constant friction of trading fees both stacking the deck against a retail trader, mean trading crypto is necessarily a money-loser, no matter how you slice it. Unless you get lucky. In my experience, no matter what you do, no matter what you try, the losses must always add up to slightly more than the wins. If you can find and correct for any part of what’s losing you money, you just lose money in a completely different way when the next trade goes completely differently. Anything you do that will help you more if the price moves your way will hurt you more in exactly equal measure if the price moves against you. There’s nothing that wins you more money part of the time that will not lose you equivalently more money the rest of the time, and any effort to reduce the size of your losses or increase the size of your wins will increase the frequency of your losses or decrease the frequency of your wins in like proportion, or vice-versa.  There is no “edge” or “alpha” except luck.

As an empiricist, though, I know there’s still a small chance that I’m wrong unless proven otherwise, and the reason I’m still around talking to people is on the basis of that diminishing hope. If I ever do become 100% convinced that it’s just gambling, I’ll be one of those people who walked away. That day keep getting closer. 

Prove me wrong. 

May 21, 2020

Follow by Email173