How to Round Up/Down To Nearest Tick in EasyLanguage

This is how you round to the nearest tick in EasyLanguage – helpful when plotting
price based indicators. Also the formula for calculating the min tick value is given.



vars: minTick(0),testPrice(0);

minTick = minMove/priceScale;
testPrice = close * .21 * range;

// round up
value1 = testPrice + (minTick-mod(testPrice,minTick));
// round dn
value2 = testPrice - (mod(testPrice,minTick));

{mod is a call to the modulus function
 aka remainder function -- mod(12,5) = 2 -- 12/5 = 2 Remainder 2
 say ES testPrice = 1123.57
     minTick = .25
     1123.57 + (0.25 - mod(1123.57,0.25)) = 1123.57 + 0.25 - 0.07 = 1123.75}
Please follow and like us:
error

Correction to Thermostat and Bandit Description in Book

A very astute reader of the BWTSwTS2 has brought to my attention  errors in my description of the Thermostat and Bollinger Bandit algorithms. In the Thermo description I incorrectly used the words yesterday and today. The code is correct in the book. Thanks to John for finding this!

Corrected description follows:

….If today’s closing price is greater than the average of today’s high,low and close, then we feel tomorrow’s action will probably be bearish. However, if today’s closing price is less than or equal to the average of today’s high, low, and close, then tomorrow’s market will behave in a bullish manner.

In addition John uncovered a typo as well for the Bollinger Bandit description – when I stated BELOW I meant ABOVE and vice versa.

Corrected description follows:

If liqPoint is BELOW the upband, we will liquidate a long position if today’s market action  <= liqPoint.

 If liqPoint is ABOVE the dnband, we will liquidate a long position if today’s market action  >= liqPoint.

 

Please follow and like us:
error