Sometimes it is not necessary to write a complex trading system when you want to accomplish something minor in the trading environment. For example, CQG provides built-in trailing stop orders that may be placed a defined number of ticks away from the market.
To enter trailing limit orders, click the Trailing Order drop-down arrow and select Trailing Limits:
Notice the order type indicator and watermarks change:
Then place your order.
Instead of using a fixed distance to the market, I had a request to base the trailing stop on the lows of a candlestick chart. In order to accomplish this, I wrote a very simple study with two curves providing the previous bar's high and low on a chart.
Curve 1 is simply:
Curve 2 is simply:
Let’s assume I placed a manual long trade as marked on the chart above, and I want a stop loss order to trail the blue markers on the chart.
To begin, right-click one of the lines representing the HILO study and select Show HILO on Trading Interface:
On the trading interface, the two levels are represented as colored dots:
Now right-click the dot and place a sell stop order on the curve:
The order is now placed and if the value changes on the next bar, the order will follow automatically.
A pack with HILO Study is attached.