Code: Select all

`Input: `

//Price Channel

LookBack ( 7 ),

//SMA Bias Filter

MAlength ( 200 );

Variables:

Int MP( 0 ), // *** add this variable

// Price Channel

HighBar ( 0 ), LowBar ( 0 ),

// System Variables

LongBias (false),

//SMA bias filter

SMAvalue ( 0, Data2 ), // *** alias to 2nd data streams

//Trend Strength Index

TSIvalue ( 0 ),

// Adaptive Profit Target/ Entry

ProfitTarget ( 0, Data2 ) , EnterLongPrice ( 0, Data2 ) ; // *** alias to 2nd data streams

// *** Add this assignment of market position to MP

MP = MarketPosition ;

{Simple Moving Average Calculations}

SMAvalue = Average(Close data2, MALength ) of data2;

{Set Trend Bias Logic}

If Close data2 > SMAValue then

LongBias = True

else

Longbias = False;

{Trend Strength Index}

TSIvalue = TrendStrengthIndex(10) of data2;

// Adaptive Entry

IF TSIvalue[1] > TSIvalue[0] then

EnterLongPrice = Lowest(Low data2, LookBack)[1] of Data2

else

EnterLongPrice = Lowest(Close data2, LookBack)[1] of Data2 ;

{Order Logic and Entry}

If LongBias = true then

Buy (" 77 LE" ) next bar at(EnterLongPrice - 1 point) limit ;

{Trade Exit}

// Adaptive Exit

IF TSIvalue < 1.65 then

ProfitTarget = Highest(High data2, Lookback)[1] of Data2

else

ProfitTarget = Highest(Close data2, LookBack)[1] of Data2 ;

IF MP = 1 then

Sell (" 77 LX") next bar at ProfitTarget Limit;

Print("LongBias: ", LongBias, "TSI: ", TSIvalue );

http://my.jetscreenshot.com/12147/20121129-0ztb-52kb