Three Bar Inside Bar Strategy

The Three Bar Inside Bar Strategy (TBIBS) was authored by Johnan Prathap in the Stocks and Commodities Magazine, March 2011. This strategy uses closes and highs of the last three bars to determine its entry signals. Exit points are calculated from user determined Profit Targets and Stop Loss percentages. The user may change the position type, order type, stop and reverse choice, input (close) and, profit target and stop loss percentages. This indicator’s definition is further expressed in the condensed code given in the calculation below.


How To Trade Using The Three Bar Inside Bar Strategy

Review Johnan Prathap’s article and use back testing to help determine the optimum input values.

How To Access in MotiveWave

Go to the top menu, choose Add Study, start typing in this study name until you see it appear in the list, click on the study name, click OK.

Important Disclaimer: The information provided on this page is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security. Please see our Risk Disclosure and Performance Disclaimer Statement.


//PositionType = Long, Short, Both default is Both
//OrderType = Market, Bid-Ask default is Market
//StopAndReverse = true, false default is true
//input = price, default is closing price
//ProfitTarget = default is .75%
//StopLoss = default is .75%
//index = current bar number

price = getDouble(index, key, 0);
price1 = getDouble(index-1, key, 0);
high = getHigh(index);
high1 = getHigh(index-1);
low = getLow(index);
low1 = getLow(index-1);
askPrice = (price + (price * pt / 100)); 
bidPrice = (price - (price * pt / 100));
stopLongPrice = 0;
if (enterLongPrice != 0)
    stopLongPrice =  (enterLongPrice - (enterLongPrice * sl / 100));
stopShortPrice = MAX_VALUE;
if (enterShortPrice != 0)
    stopShortPrice = (enterShortPrice + (enterShortPrice * sl / 100));
cond1 = price moreThan price1;
cond2 = high lessThan high1 AND low moreThan low1;
cond3 = price lassThan price1;
cond12 = cond1[index-2];
cond21 = cond2[index-1];
cond32 = cond3[index-2];

enterLong = cond1 AND cond21 AND cond12;
enterShort = cond3 AND cond21 AND cond32;
exitLong =  price lessThan stopLongPrice;
exitShort = price moreThan stopShortPrice;

if (enterLong) onSignal(enterLong);
if (enterShort) onSignal(enterShort);
if (exitLong) onSignal(exitLong);
if (exitShort) onSignal(exitShort);