Three Bar Inside Bar Strategy

Hello, I am trying to build a three-bar signal strategy, can somebody help me write the script?
This strategy uses the 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.

I have this script from the motive wave software but I like to write this script.

//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);

Appreciate your help.