Tuesday, October 2, 2012

[Tradestation] Breakout Range

In EasyLanguage, you can create a Boolean variable or a ShowMe studyto simply test whether the two conditions of a breakout are met. However, I thought it more useful to have the function return the numberof bars since the last time a new high was achieved. The only time a numberother than zero is returned is when it is a true breakout (the functionwill return a zero either when no new high is achieved or when a new highhas been achieved, but it has not been a breakout of look_bak length orgreater).















input : N1(20), N2(18);
var : count(0);
if count >= N1 && H > highest(H,N1)[1] then
{buy(); count = 0;}
if BarsSinceEntry == N2 then
exitlong();
if h <> highest(H,N1) Then
count = count + 1;
*/

Inputs: look_bak(20),
n_bars(18);
Vars: bar_count(0), max_price(h),Breakout_Range2(0);
If CurrentBar == 1 then {
bar_count = 1;
}
Else {
If H > Highest(high, look_bak)[1] then {
if bar_count >= look_bak then {
Breakout_Range2=bar_count;
bar_count = 0;
}
Else {
bar_count = 0;
Breakout_Range2 = 0;
}
}

Else {
bar_count = bar_count + 1;
Breakout_Range2 = 0;
}
}
If Breakout_Range2 <> 0 then
Buy() ;
If BarsSinceEntry >= n_bars then
ExitLong();

1 comment: