Monday, 27 December 2021

Better Volume Indicator

 BVI improves on your typical volume histogram by coloring the bars based on 5 criteria:

Volume Climax Up – high volume , high range, up bars (red)
Volume Climax Down – high volume , high range, down bars (white)
* High Volume Churn – high volume , low range bars (green, barcolor= blue)
* Low Volume – low volume bars (yellow)
Volume Climax plus High Volume Churn – both the above conditions (magenta)

When there are no volume signals the default histogram bar coloring is cyan.

Bars can also be colored to match volume color. Enable "Change BarColors?" in the options page.

Volume Climax Up bars are typically seen at:
* The start of up trends
* The end of up trends, and
* Pullbacks during down trends.

The beginning of an up trend is almost always marked by a Volume Climax Up bar. This shows that the buyers are anxious to get on board and large volume enters the market and bids up prices quickly. A valid breakout should be followed by more buying but occasionally the low of the Volume Climax Up bar is tested.

Volume Climax Down bars are typically seen at:
* The start of down trends
* The end of down trends, and
* Pullbacks during up trends.

High Volume Churn bars are typically seen at:
* The end of up trends
* The end of down trends, and
* Profit taking mid-trend.

Low Volume bars are typically seen at:
* The end of up trends
* The end of down trends, and
* Pullbacks mid-trend.

More information can be read here: https://emini-watch.com/free-stuff/volume-indicator/

Saturday, 27 November 2021

Some TV Indicators I like

 TL Enhanced volume

TraderLion’s Enhanced Volume has the following features highlighted below.

  1. High Relative Volume Bars: Clearly highlight high relative volume bars with a high closing range lime green for the best interpretation of volume on your Daily & Weekly Charts.
  2. Low Relative Volume Bars: Clearly labels low relative volume days with a down arrow to interpret constructive price & volume action on your Daily & Weekly Charts.
  3. Volume Labels: High volume days are labeled to show 2 things: Total shares traded and Percent above average
  4. Highest Volume in Over a Year: Look for the letters HV on top of the volume bar to identify this powerful characteristic.
  5. Simple Moving Average: SMA overlay on your volume without taking up limited indicator slots.
  6. High Relative Volume Alerts: Set alerts that trigger when the volume surpasses the High Relative Volume Threshold.

TL Relative Strength

  1. Pink Dot symbolizes the RS Line reaching new highs before price. RS New Highs Before Price (RSNHBP) is often indicative of a break out emerging.
  2. Direction-Based Relative Strength . When the line moves up it will be blue, and on the way down pink. Easily glance and see phases of relative strength on the chart.
  3. Raw RS Rating - The RS Line Script features an RS Rating from 1-99 with 99 being the strongest rating. The measures the stock’s performance relative to the Index you input.

Curvature of Meniscus 

is a hybrid indicator comprised of three parts:

  1. The first part is a heavily modified Demarker RSI which is represented as the histogram and is the main trend indicator C1.
  2. The second part is the 0 line which is replaced by the Waddah Attar Explosion V2 indicator C2.
  3. The third part is the background color which is borrowed from the Klinger Safety Zones volume indicator Vol.

It is smooth and has almost zero lag. The signals can be used as per nnfx C1-C2-Vol algorithm.

  • The DeMarker indicator is relatively unknown to trading beginners but enjoys huge support from the more experienced traders. 
  • The indicator measures the strength of a trend and thus can give you a warning when a change in the trend direction might occur. 
  • This can not only help you to find new trade entries but also prevent you from entering into losing trades or letting your open trades  run and ultimately result in a loss.

The line of the indicator is calculated as follows: First the indicator finds the minimal and the maximal value of the specified period. 

Afterwards those values are used to calculate the moving average of these values which then is displayed in the chart. Just like most oscillators the DeMarker indicator uses oversold and overbought zones at 0.3 and 0.7 to define good entry opportunities.

The "Curvature of Meniscus" indicator has the DeMarker indicator/ RSI modified in three different ways:

  1. Smoothed and almost no-lagged;
  2. Colored histogram to determine the trend and the divergences;
  3. An early signal line for those who like to take counter-trend trades/reversal entries.

TraderLion Reversal Bars 

  • Oops Up - Price opens below prior day’s close and closes above. Concept by Larry Williams
  • Kicker - When the prior day closes down and the current day gaps above the entirety of yesterday’s action signaling a clear momentum change.
  • Three Bar Break - Price breaks above prior 3 closes and closes above on above-average volume .
  • Upside Reversal - Today’s price undercuts the prior day’s low but closes the day on a >= 50% closing range
  • Power of 3 - Power of 3 shows the strength and demand of stock to get through the 3 widely followed moving averages (10, 21, 50 daily moving averages)
  • Outside Bullish / Bearish Day - Price closes above/below the prior day’s high/low.
  • Up/Down volume ratio. IBD defines U/D ration as "A 50-day ratio that is derived by dividing total volume on up days by the total volume on down days. A ratio greater than 1.0 implies positive demand for a stock"

Consolidation - Squeeze Indicator


LizardIndicators’ Squeeze Indicator:

The Squeeze indicator identifies one of the following scenarios:

  • Low volatility squeeze: Occurs when the standard deviation reaches a period of low volatility, compared to the 120 bar lookback period.
  • Consolidation squeeze: Occurs when the Bollinger Bands narrow in width, moving inside the Keltner channels (range bound market).
  • Full squeeze: Occurs when both of the above scenarios apply at the same time, i.e. low volatility as indicated by standard deviation for the lookback period, and low true range volatility.

For the Bollinger Squeeze, we want low volatility (but not minimum) when compared to the 120 bar lookback period. By default, the threshold is set to 1.2. By increasing this value, the low volatility definition will become more stringent, effectively delivering fewer low volatility setups.

All of the above squeeze indicator breakouts must be aligned by two momentum periods, 10 and 25 bars. Also, in order to eliminate distortions from the lookback period (and reduce noise signals), the Balanced Momentum calculation is used

Finally, the squeeze indicator breakouts have to confirmed by price action, i.e. Thrust Bars. For long signals, the signal bar has to close above the high of the previous bar. For short signals, the signal bar has to close below the low of the previous bar.

Source:  https://www.lizardindicators.com/squeeze-indicator/


Conditions for a robust strategy

 I had read this somewhere and noted but do not remember the source. When backtesting any strategies on TradingView, we need to compile various parameters that arise for a strategy. 

  • Minimum of 100 trades (prefer multiple hundreds)
  • At least 10 years of data (use all the data you can find)
  • A statistical significance factor  [ Profit Factor * sqr ( number of trades ) >= 30 ]
  • 20% or more Out-of-Sample data used
  • Out-of-Sample Profit Factor divided by In-Sample Profit Factor > 70
  • Net Profit divided by Max Drawdown > 10
  • Over all Profit Factor >= 2

Score = Profit Factor * sqr ( Number of Trades )  * ( Net Profit / Max Drawdown ) * ( Out-of-Sample Profit Factor / In-Sample Profit Factor )

  • Any strategy that scores above 400 is worth trading.
  • Score should be preferably above 30

Saturday, 6 November 2021

Delta of an ATM option and more

 According to most books the ATM option is the option with a delta of 0.50. However, this is only the case when the distribution is normal. The more positively skewed the distribution, the further the 0.50 delta option is out-of-the-money (for calls). 

The formula to calculate the 0.50 delta option strike is equal to: S . e^(σ^2/2)


Interesting Observations About Options

  • Even in a continuous distribution, the higher the volatility, the more positively skewed the distribution, the further OTM the 50d call strike lives.
  • The cheapest straddle will occur at the median outcome or the ATM strike. 
  • The most expensive butterfly will have its “body” near the theoretical mode. This makes sense since a butterfly which is just a spread of 2 vertical spreads is a pure bet on the distribution. If you chart the price of all the butterflies equidistantly across strikes you will have drawn the probability density function implied by the options market!
In Black Scholes:
  • The term for delta is N(d1).
  • The term for the probability of finishing in the money is N(d2).

What’s the relationship between d2 and d1?

  • d2 = d1 – σ√t

The math defines the relationship we figured out intuitively:

The higher the volatility the more delta and probability will diverge!

Delta and probability are only similar when an option is near expiration or when it’s vol is “low”.


For more read: 

https://moontowermeta.com/lessons-from-the-50-delta-option/



Tuesday, 9 March 2021

Running models on the cloud

Jupyter Notebook is the most popular tool for doing data science in Python. It is powerful, flexible, and easy to use. 

There are online platforms available where you can upload your Jupyter notebooks and run your code on the cloud. It is better that you run your code on any of these and not use your own computer, unless you are very experienced in Linux administration and handling GPU drivers. 

  • Colab: A popular free service from Google. 
  • Gradient: Works like real Jupyter notebook and you can save your models and notebooks. 
  • DataCrunch.io: no setup required, extremely good value and extremely fast GPUs, or 
  • Google Cloud: extremely popular service, very reliable, but the fastest GPUs are expensive.
  • JarvisLabs.ai:- With Jarvis Cloud you get a GPU powered Jupyter notebook pre-configured with all the necessary software in less than 30 seconds.
  • Azure:- You can use Azure Data Science Virtual Machine (DSVM) which is a family of Azure Virtual Machine images, pre-configured with several popular tools that are commonly used for data analytics, machine learning and AI development.
     
I have been using Colab till now and it has worked for most of the tasks. It is better to optimize your code to work on the given machine configuration as there are number of ways to reduce compute requirements. Keep experimenting!

Numerai - The Financial Machine Learning Competition

Numerai is the hardest data science tournament in the world as it aims to build the world's last hedge fund. 

You have to apply machine learning to predict the stock market on the data shared by Numerai. 

This is a very good comprehensive guide for the competition: 

https://tit-btcqash.medium.com/a-comprehensive-guide-to-competing-at-numerai-70b356edbe07

Couple of Kaggle notebooks also give a quick start to the competition as you aim to build a model and then stake real dollars to earn money.

https://www.kaggle.com/code1110/numerai-tournament

https://www.kaggle.com/carlolepelaars/how-to-get-started-with-numerai


I will aim to share my Numerai journey in the future blogs. 








Saturday, 6 March 2021

Stocks Data

 Let's look at various service providers for data for equities:

a) Tiingo- From $0 a month to  $10 a month. It provides an API to access the data.

b) FMP Cloud:- $14/month wit unlimited requests. 

c) Zerodha:- Rs. 4000/m which is approx $ 55/month provides the historical data API linked to Kite Connect. 


Friday, 5 March 2021

Stripe Atlas - Incorporating company in the US

 Recently heard of Stripe Atlas, a service by Stripe to incorporate your company in the US from anywhere on the globe. 

Services provided include almost everything required to set up a startup and costs $500 currently: 

  • Formation of a company in Delaware 
  • Delaware state filing fees 
  • Signed documents to establish company bylaws and protect IP 
  • Tool to issue stock to founders 
  • First year of registered agent fees 
  • Tax ID (EIN) filing 
  • Stripe Atlas Community membership
  • Free templates for post-formation legal needs 
For more, you can refer to https://stripe.com/atlas


LSTM Model

 This is a pretty good guide to LSTM: 

https://towardsdatascience.com/illustrated-guide-to-lstms-and-gru-s-a-step-by-step-explanation-44e9eb85bf21

Youtube video: https://www.youtube.com/watch?v=8HyCNIVRbSU


A research paper from Stanford looks at using the model for market prediction: 

http://cs230.stanford.edu/projects_winter_2020/reports/32066186.pdf




Thursday, 4 March 2021

Depth First Learning

If you haven’t heard of it, Depth First Learning is a wonderful resource for learning about machine learning.

Grown out of a Google AI residency, the DFL program builds curricula around specific ML papers.  DFL has built an entire self-paced class, with background reading, lectures, and practice problems, that culminates in the paper itself. So far, they’ve built guides like this for DeepStackInfoGAN, and TRPO.

This is  advanced stuff in ML but if you go that far, you should surely have a look at DFL!

Kudos to the team! 

L2 Regularization and Batch Norm

So to a first-order approximation, once you are using batch normalization in a neural net, an L2 objective penalty term or weight decay no longer contribute in any direct manner to the regularization of layers that precede a batch norm layer. Instead, they take on a new role as the unique control that prevents the effective learning rate from decaying over time.

This could of course itself result in better regularization of the final neural net, as maintaining a higher learning rate for longer might result in a broader and better-generalizing optimum. But this would be a result of the dynamics of the higher effective learning rate, rather than the L2 objective penalty directly penalizing worse models.

Of course, this analysis does not hold for any layers in a neural net that occur after all batch normalization layers, for example typically the final fully-connected layers in common architectures. In those layers, obviously the normal regularization mechanism applies. Other variations on architecture might also affect this analysis. And as mentioned near the start of this post, if you are using an optimizer other than stochastic gradient descent (or stochastic gradient decent with momentum - the analysis is very similar), things might also be a little different.

Source: https://blog.janestreet.com/l2-regularization-and-batch-norm/