Simple Graybox Technique: Colorizing Background

Graybox Trading

Mar 06

A simple but effective technique for building your first graybox is to colorize the background based on whether you should be looking for short or long trades and/or based on identification of specific setups. A key benefit over simply using traditional indicators is that it eliminates the effort and tedium required to process multiple indicators. This provides a real advantage especially for the very active trader. It eliminates the chart clutter and noise, as well.

In the example shown, I used some simple indicators to classify the market into 4 states and then colorize the background. The example code is for Ninjatrader 7. While still rudimentary at this stage, I do not share the ranking criteria. But, my process and goal was to find some indicators to help filter the market, in order, to help me focus on looking for long or short trades.

One particular aspect that I like about colorizing the background versus displaying buy and sell signals is that I found in the past that seeing buy and sell signals would often strongly bias my perception of the market, and seeing the signals made me less perceptive of the market and more likely to trade mechanically. In the example shown, we can have multiple degrees of confidence for long or short trades or different classifications of regimes.

if (rank ==2)
BackColorAll= Color.FromArgb(75,20,150,50);
if (rank ==1 )
BackColorAll= Color.FromArgb(75,20,250,50);
if (rank ==-1 )
BackColorAll= Color.FromArgb(75,250,50,50);
if (rank ==-2 )
BackColorAll= Color.FromArgb(75,150,100,100);

Example shown is for example purpose only. The settings are not calibrated for the chart shown.

About the Author

The author is passionate about markets. He has developed top ranked futures strategies. His core focus is (1) applying machine learning and developing systematic strategies, and (2) solving the toughest problems of discretionary trading by applying quantitative tools, machine learning, and performance discipline. You can contact the author at