Windicator update links

At any time if you see errors like plugin update required or incompatible bridge version, then use these links to update your copy, they contain newest build.

Current release 20190916

Stable release 20190711

How to install AmiBroker Plugin

  1. Copy librtWindicator.dll file in “C:\Program Files (x86)\AmiBroker\Plugins\
  2. Copy amibroker.conf in “C:\Program Files (x86)\AmiBroker\
  3. For our strategy, use AFL file on charts
  4. For custom strategy, include on your AFL.

How to install Order bridge (Robo)

  1. Create a folder in a safe place
  2. Copy libVaca.dll inside that folder
  3. Copy Windicator.exe inside also in same folder.
  4. Set from windows Windicator.exe “run as administrator”
  5. You also need to set your AmiBroker “run as administrator”
  6. Now double-click on Windicator.exe just to ensure it’s working
  7. Make sure any one of the premium strategy ( eg Smart trend follow ) is subscribed in your account at, otherwise robo will not work
  8. Add required columns in nest trader, for details refer setup guide

Make sure Plugin can connect to server

  1. Unless plugin connects to our server,
  2. You won’t see any buy/sell signals
  3. You won’t be able to use bridge functionality
  4. Take a look at status line on top-left side in charts.

Last stable 20190628 (Changed DLL, AFL )


Correlation coefficient stock vs NIFTY – 5min table

Correlation coefficient or mathematically speaking auto-correlation tells the strength of positive or negative relationship of the price movement between two instruments, this comparison is valid for Index-component, or stock-commodity for almost everything.

A positively high value of coefficient means stock tends to rise if the index goes up whereas a high negative value means stock loses value if index goes up, in either case, a near zero value means, there is not much relationship exist between the two instruments.

Below is the list of some commonly traded stocks Correlation coefficient;

Relationship wrt NIFTY, timeframe=300s

ASIANPAINT-EQ 0.0906 30/05/2019 19/06/2019
AUROPHARMA-EQ 0.0580 30/05/2019 19/06/2019
AXISBANK-EQ 0.0796 30/05/2019 19/06/2019
BAJFINANCE-EQ 0.3252 30/05/2019 19/06/2019
BANKNIFTY 3.0738 30/05/2019 19/06/2019
BHARTIARTL-EQ 0.0263 30/05/2019 19/06/2019
BIOCON-EQ 0.0199 30/05/2019 19/06/2019
BPCL-EQ 0.0359 30/05/2019 19/06/2019
DABUR-EQ 0.0163 30/05/2019 19/06/2019
DRREDDY-EQ 0.1857 30/05/2019 19/06/2019
GODREJCP-EQ 0.0495 30/05/2019 19/06/2019
GRASIM-EQ 0.0695 30/05/2019 19/06/2019
HCLTECH-EQ 0.0761 30/05/2019 19/06/2019
HDFCBANK-EQ 0.1588 30/05/2019 19/06/2019
HINDUNILVR-EQ 0.1104 30/05/2019 19/06/2019
IBULHSGFIN-EQ 0.1685 30/05/2019 19/06/2019
ICICIBANK-EQ 0.0435 30/05/2019 19/06/2019
INDUSINDBK-EQ 0.2849 30/05/2019 19/06/2019
INFY-EQ 0.0340 30/05/2019 19/06/2019
JETAIRWAYS-EQ 0.0082 30/05/2019 19/06/2019
JUBLFOOD-EQ 0.1052 30/05/2019 19/06/2019
KOTAKBANK-EQ 0.1469 30/05/2019 19/06/2019
LICHSGFIN-EQ 0.0441 30/05/2019 19/06/2019
LT-EQ 0.1035 30/05/2019 19/06/2019
LUPIN-EQ 0.0571 30/05/2019 19/06/2019
M&M-EQ 0.0614 30/05/2019 19/06/2019
NIFTY19JUNFUT 0.8469 17/06/2019 19/06/2019
RELIANCE-EQ 0.1472 30/05/2019 19/06/2019
SBIN-EQ 0.0426 30/05/2019 19/06/2019
SRTRANSFIN-EQ 0.1917 30/05/2019 19/06/2019
SUNPHARMA-EQ 0.0330 30/05/2019 19/06/2019
TATASTEEL-EQ 0.0492 30/05/2019 19/06/2019
TCS-EQ 0.1588 30/05/2019 19/06/2019
TECHM-EQ 0.0388 30/05/2019 19/06/2019
TITAN-EQ 0.0957 30/05/2019 19/06/2019
UPL-EQ 0.0607 30/05/2019 19/06/2019
WIPRO-EQ 0.0072 30/05/2019 19/06/2019
YESBANK-EQ 0.0274 30/05/2019 19/06/2019
ZEEL-EQ 0.0431 30/05/2019 19/06/2019

AmiBroker backtest with fixed number of quantity

By default AmiBroker backtesting engine, sets some Initial capital and displays ending capital in backtest result, but more often we need to backtest a strategy with a given number quantity instead of how much trading capital we have, as later criteria can pose problems with options where If one has fixed the trading capital, then number of traded quantity might vary over trades.

To do this we only need to add one line towards the start of AFL file

 SetPositionSize( 1, spsShares ); 

Here 1 being quantity, also if you are backtesting multiple symbols it is preferred to set max number of open position to 1000, this can be done from
Analysis window -> backtester settings -> portfolio tab

AmiBroker custom bar colors buy sell AFL

Following piece of code is for drawing, coloured bars/candles that changes its colour with signal, it makes easy to understand working of strategy.

color = IIf(Flip(Buy, Sell), colorLime, colorLightGrey);
color = IIf(Flip(Short, Cover), colorRed, IIf(color != colorLightGrey, color, colorLightGrey));
Plot(C, "C", color, styleCandle);


Note that all four variables buy, sell, short, cover must be set in AFL somewhere before above code starts, a sample working AFL may look like below;


ma1 = ma(c, 10);
ma2 = ma(c, 30);

buy=cover = cross(ma1, ma2);
sell=short = cross(ma2, ma1);

color = IIf(Flip(Buy, Sell), colorLime, colorLightGrey);
color = IIf(Flip(Short, Cover), colorRed, IIf(color != colorLightGrey, color, colorLightGrey));
Plot(C, "C", color, styleCandle);

A sliding window implementation of AR(1) model for financial time series

Below is working c++ equivalent code snippet I am sharing for curious readers, the auto-correlation regression, also known as AR model are popular and classic method for analysis and forecasting time series such as stock prices. AR models comes with many varieties of which AR(1), the single lag is simplest and easier to implement by programming ordinary least square (OLS), understanding this will form basis for developing your own higher order AR models. correlation coefficient obtain using this method can be readily used for Unit root test, to find out whether our time series is stationary.

Without further ado, sharing a sliding window based ( aka moving window ) implementation which are must for all kinds of performance oriented algos, please read code comments, they are there for some explanation.

#include <iostream>
#include <stdio.h>

	Subject: AR(1) model examplde code

int main() {

	int n = 10000;// entire price array length
	int pds = 10; // moving window period
	///// this is a virtual stock closing price, 
	///// in reality it will be obtained from your charting software
	double* close = new double[n]();
	close[0] = 1000; // starting price
	for(int i=1; i < n; ++i) { 
                if(std::rand()%10 > 5) {
			close[i] = close[i-1] + 1;
		} else {
			close[i] = close[i-1] - 1;


	double* input = new double[n](); // prepare an empty time series input - 0 filled
	double* array = new double[n](); // array to hold predicated values
	// below allocating 0 filled arrays in heap 
	double* _sumx = new double[n](); 
	double* _sumy = new double[n]();
	double* _sumx2 = new double[n]();
	double* _sumxy = new double[n]();

	for(int i=1; i < n; ++i ) { // starting the loop from 1 
                input[i] = close[i] - close[i-1];  // this is for 1st order differencing 
                                                                        // one can also use close[i] 
                double y = input[i]; // return 
                double x = input[i-1]; // lag-1 value for return 
                _sumx[i] = _sumx[i-1] + x; 
                _sumy[i] = _sumy[i-1] + y; 
                _sumx2[i] = _sumx2[i-1] + x*x; 
                _sumxy[i] = _sumxy[i-1] + x*y; 
                if( i > pds - 1 ) {
			double y_old = input[i-pds];
			double x_old = input[i-pds-1];
			_sumx[i] -= x_old;
			_sumy[i] -= y_old;
			_sumx2[i] -= x_old * x_old;
			_sumxy[i] -= x_old * y_old; 
			double var = pds*_sumx2[i] - _sumx[i]*_sumx[i];
			double cor = (pds*_sumxy[i] - _sumx[i]*_sumy[i])/var; // correlation coefficient can be 
			double fix = (_sumy[i]*_sumx2[i] - _sumx[i]*_sumxy[i])/var;
			array[i] = fix + cor * input[i-1] + close[i-1];  // predict current closing using lag-1
			printf("i=%d	actual= %.2f		forcast= %.2f\n", i, close[i], array[i]);

Now comppile it with
g++ -std=c++11 ar1.cpp

Which is more important win-rate or risk-reward ratio ?

Every traders must have come across this epic question of which one to give more value, high winrates or high risk-reward, winrate is – how many of your % trades tend to come out profitable, you can have a 60% winrate which is considered decent, for many experienced traders with 70-80% win rates are not uncommon, on the other side risk-to-reward ratio, is basically how much typically you make against your losers, a 1:1 of risk-reward works well most of the time, the higher the better.

When we design a strategy, algorithmic or price pattern, it will have a characteristic winrates and risk-reward, some strategy have high winrate and low risk/reward, and reverse is also true, by evaluating these we can either discard or accept that particular strategy, because it must have acceptable winrate and reward ratio both, note that a high winrate with very poor risk-reward is not useful similarly a high risk-reward but loses quite often is equally bad, therefore when we say high winrates that means, risk-reward is also fixed, typically 1:1.

This article is for day traders and not a investing or positional trading material, for investing or any long term trading clearly the focus must be towards high reward/risk ratio. you maybe losing 7 out of 10 traders but those 3 winner will make up for all losses. Warren buffet will tell you how much he loves high reward to risk and lots of buffet folks will advice you the same, but is it one fit for all? is it good for everyone, not so simple.

As we know, winrate and risk-reward runs contrary to each others, you can’t have both in favour, means for a higher profits one has to give up some portion of from winrates and vice versa, so again the same question arise, which one is more valuable – winrate or reward to risk? Let me again clarify this guidance is only for day trading. and for day trading winrates are more important than risk to reward ratio.

Why it is so, to figure out this we must understand significance if both, winrate and risk-reward, a lower winrates simply means you are doing something wrong in your analysis or make mistakes, perhaps your market knowledge is not up to the level or you lack psychological robustness, whereas a consistently high winrates means you are right path. Second the higher risk-reward means you as a trader have been able to develop a stable mind and patience. so reality is both are important but not equally for everyone, typically in the beginning of your trading career you must focus on high winrates, combined with at least 1:1 risk-reward, later when you have mastered trades, you should be improving on reward to risk, because your experience has already made you the master of trades and don’t make mistakes.

To sum up, aiming for high risk-reward comes later in the trader learning phase, and don’t fall for anyone who is giving you a black and white answers.

How adding more indicators does not increase profits

To answer this in a deterministic manner and not to confuse you further, I would first ask you to throw another important question – whether the indicators you have posses any real edge in market? By edge I mean winning tendency over and above 50%, so if your indicator have winning tendency of 56% then it has edge of 56-50 = 6%, notice that 50 is discarded, and does not become the part of our overall edge calculation. To be clear, I should mention that win rates are calculated using strategy back-testing over a sufficient time series data.

Why, we eliminated 50 part of winrate is because all kinds of financial market provides you a default edge of 50%, without doing anything on your part, basically it just means that, in an efficient markets at any points of time the tendency to go up or go down are always the same, no matter what strategy we deploy. We know that markets are not 100% efficient but for most mathematical model based strategies this still holds a solid ground. Therefore 50% is not an edge in reality, when we combine anything of 50-50 probability it will not enhance our win rate anyway, this is what our probability theory also tells us.

Lets run through a very simple example for our understanding, lets say we have three indicators A, B and C of win rates 50% each, in a mathematical language, when an indicator A is true state we have 50% probability of winning, and same goes for B and C. Now we are asking when A, B or A, B, C have simultaneously true states that time whats the winning edge ? is it more than 50 or less !!

As you figured out, they all have 0 (50-50) edge, therefor when system is stacked by A+B+C,additional stacking do not change existing edge any further.

To put it in simple words, only if an indicator have over and above 50% edge, then combined with another indicator could results in further improvements of overall winning probabilities, and we know that most of our indicators have 50% or less (most are in range of ~35%) win rates, they become less than 50% because of brokerage and late entries, so by now it should be clear, that such combination stacked up together cannot lead you to a more profitable trading system.

Why it is extremely difficult to make dependable income from investing ?

Stock market investing or a mutual funds investment, basically any long term parking of your money in stock market won’t pay you cash if you expect a living from that, well it can make you rich if you are already wealthy, unfortunately you can’t use that money.

Let’s understand the paradoxical nature of investing income, and how the whole investment talks are merely media gimmicks floated out of con industry propaganda. Let me also put a disclaimer that knowledge gained from doing investment activity is very precious, if you know how to make use of that.

If you take my words, only two kinds of people who should be able to generate any profit doing investment, are 1. rich people who buy stocks and forget, they don’t need to en-cash profit for decades, it’s like putting your money in a piggy bin but you are not going to take it out, means you are virtually rich but your life is not improving, over the years valuation of your stocks will rise and make you feel happy but again you are not supposed to sell the stocks. This is a paradox, fooling those wealthy people that they are making best use of their time.

Second category of people are the fund managers who get commissions from this entire work, so whether your portfolio rise or fall they get a buck, these are the con men’s of industry, their lobbying system is so powerful and spread false ideas about markets, they do this all the time, like – you must never day-trade and always invest for long term, you must understand they are saying for their own sake not for you. Fact is that historically no funds have consistently proven track records, index funds however might perform better if the countries economy is in good track.

Let me be simple and state two reasons why investing in stocks cannot pay for your bills, of course it can increase your wealth if your are already wealthy, sounds weird …huh!.

First difficulty with investing is, it requires huge sum of capital without which you won’t be able to buy and hold significant amount of shares, most medium income people buy 50-100-500 stocks and yearly return maybe ( not at all guaranteed ) 15-20%, this money won’t even pay for your telephone bills. Now compare this to ace investors, who unlike ordinary guy, smartly plays the game of scale, each extra point rise in stock makes millions of change in their portfolio, they also manage others money for a commission so it makes more sense to them.

Large number of folks venturing into investing-mania, are drawn by buzzword repeated over and over again and hypnotized by this media propaganda, they end up doing it more like cultural craze where lot of similar people are doing the same thing, but remember media makes investing look romantic and adventurous only because they are paid by fund managers to do that, so as these fund manages are assured of consistent commission from a large pool of money where the inflow is never dried.

Second issue with investing as I said earlier, you are not supposed to sell your shares and remain invested, until you die. therefore it make sense for rich people’s who need to park their extra money somewhere without bothering what happens to it.its a paradox!!