Category Archive : Free Scripts & Algos Even Though You Probably Don’t Deserve It

Reminder Message (w/ color picker demo)



Reminder Message (with color picker) – ApopheniaPays by ApopheniaPays on TradingView.com

TradingView Script. Free TradingView account required to use. Direct link: https://www.tradingview.com/script/KLNJvOaF-Reminder-Message-with-color-picker-ApopheniaPays/

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.com

TradingView Script. Free TradingView account required to use. Direct link: https://www.tradingview.com/script/NwvUwIQ3-Demonstration-of-how-history-length-affects-all-EMA-values/

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.com

TradingView Script. Free TradingView account required to use. Direct link: https://www.tradingview.com/script/vQmYyTp5-ApopheniaPays-Range-Strategy

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.com

TradingView Script. Free TradingView account required to use. Direct link: https://www.tradingview.com/script/Hgjz7wXW-AP-VWWMA-Volume-Adjusted-Price-lines-5-4-2-shared-alpha/

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.

WHAT TH’ HECK ARE ALL THESE 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 .

HOW I USE THIS:

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.

YEAH, BUT WHAT ARE THESE? HOW ARE THEY CALCULATED?

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: https://twitter.com/ApopheniaPays/status/1209777737579155456
Calculating a Volume-Adjusted Price line: https://twitter.com/ApopheniaPays/status/1208979072711180288
A slight correction to the formula for Volume-Adjusted Price lines: https://twitter.com/ApopheniaPays/status/1211872536432005120
Overview of reading the VAP lines: https://twitter.com/ApopheniaPays/status/1214053445029679105
Some inconclusive musings on how VAPs move and predict pumps and dumps: https://twitter.com/ApopheniaPays/status/1221596657097138176

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.com

TradingView Script. Free TradingView account required to use. Direct link: hhttps://www.tradingview.com/script/cviFZ4S5-AP-Risk-Management-Assistant-20-02-25-01-shared-alpha/

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

—–

A word about the “regretted sale” features:

BUYBACK SPOT PRICE AFTER ‘REGRETTED’ SALE:

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.com

TradingView Script. Free TradingView account required to use. Direct link: https://www.tradingview.com/script/izM2anXV-ApopheniaPays-Crossing-detector-2-field-date-time-entry/

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.

RSS2k
Follow by Email173
Facebook42