Back to links
    3-4 Bar Pattern Strategy

ALERT posted 4/15/2014: Although I cannot confirm this because I can no longer test these codes, I have been informed that the above 3-4 Bar Strategies requires that anyone using this code should add a "Look-inside bar" function to avoid issues with Intra-bar Price Movement Assumptions. This is not included in the code below. This link is provided as a reference.

Anyone using information or codes on these pages does so at their own risk - no guarantees of stability or profitability are claimed. These codes are all for testing purposes only. Copy everything in the bottom panel and paste into a new strategy.

////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// 3-4 BAR PATTERN TRADES ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////

// Set the TradeType based on the patterns drawings in the 3-Bar Pattern PDF
//Input: TrailFloor(1), TrailAmt(0.01);

////////////////////////////
///// TRADE VARIABLES //////
////////////////////////////

Var: TradeType (0), MultiX (true);{Multiple exits can be turned on here or below in "MultiExits"}
Var: Series3Low(0), Series4Low(0), Series5Low(0); //declare variables

TradeType=1; //////// SET TradeType 1-9 including 7.2 Here /////////////////

Series3Low = Lowest (Low, 3); Series4Low = Lowest (Low, 4); Series5Low = Lowest (Low, 4); //define variables

/////////////////////////
///// TRADE ENTRIES /////
/////////////////////////

If TradeType=1 //$PF 1.65
and H[3]>H[2] and C[2]<C[1] and L[1]>L[2] and H[1]>H[2] and H[0]>H[3] then
Buy ("T1Long") Next Bar at H[3]+ .0001 stop;
If TradeType=1 and MarketPosition = 1 then begin; SetStopContract; SetPercentTrailing (.002, -.002); end;//(floor amount, stop)

If TradeType=2// or TradeType=2.1 //$PF 2.19
and H[3]>H[2] and C[2]<C[1] and L[2]<L[3] and O[1]<C[2] and C[1]>C[2] and L[1]<L[2]
Then Buy Next Bar at H[2]+ .0001 stop;

If TradeType=3 //$PF 3.59
and H[3]>H[2] and C[2]<C[3] and O[1]>C[2] and H[1]>H[3] and H[0]>H[1]
Then Buy Next Bar at H[1]+ .0001 stop;

If TradeType=4 //long //$PF 2.53
and H[3]>H[2] and H[2]>H[1] and L[3]<L[2] and L[2]<L[1]
Then Buy Next Bar at H[3]+.0001 stop;

If TradeType=5 //short //$PF 0.23 why so bad compared to long?
and H[3]>H[2] and H[2]>H[1] and L[3]<L[2] and L[2]<L[1]
Then sell short next bar at L[3]-.0001 stop;

If TradeType=6 // $PF 3.6
and H[3]>h[2] and C[2]<C[3] and O[1]>C[2] and H[1]>H[3]
Then Buy Next Bar at H[1]+ .0001 stop;

If TradeType=7 //$PF .53
and L[4]<L[5] and L[3]<L[4] and H[5]>H[4] and H[4]>H[3]
and H[2]<H[3] and H[1]<h[3] and L[2]>L[3] and L[1]>L[3] //and a series of 2 small inside bars
Then Sell Short Next Bar at H[1]- .001 stop;

If TradeType=7.2 //$PF 3.77
and L[5]<L[6] and L[4]<L[5] and H[6]>H[5] and H[5]>H[4]
and H[3]<H[4] and H[2]<H[4] and H[1]<h[4] and L[3]>L[4] and L[2]>L[4] and L[1]>L[4] //and a series of 3 small inside bars
Then Sell Short Next Bar at H[1]- .001 stop;

If TradeType=8 //$PF 1.62
and H[4]<H[3] and C[3]>C[2] and C[2]<C[3] and O[1]<C[2] and C[1]>C[2]
Then Buy Next Bar at H[3]+ .001 stop;

If TradeType=9 //$PF .34
and H[3]<H[4] and C[3]>C[4] and H[2]>H[3] and C[2]<C[3] and L[1]<L[3] and C[1]>C[3]
Then Buy next bar at H[2]+.0001 stop;

///////////////////////////
////////// Exits //////////
///////////////////////////
//This exit group (declared as MultiExits below) can be turned here or at "MultiX" top of page. Set to "false" in BOTH places to turn it off.
{This exit strategy group includes stops and targets. It's set for divergence from the entry price instead of a specific price point.
There is a stop, a profit target, a breakeven stop, 2 different trailing stops, and an end-of-day exit.
This will exit your entire position, either long or short.
IntrabarOrderGeneration is set to false because these commands evaluate intrabar even when intrabar order generation is disabled.}
[IntrabarOrderGeneration = false]
var:{these are exit inputs: Suggested Starting Points (SSPs) are for EUR and similar denominated Forex instruments}
MultiExits(false),
ShareOrPosition( 1 ), //1 = per share basis, 2 = position basis
ProfitTargetAmt( 0 ), //SSP .005 or 0 if you don't want a specific profit target
StopLossAmt( .005 ), // SSP .007 or 0 if you don't want a stop loss
BreakevenFloorAmt( 0 ), //SSP .006 or 0 if you don't want a breakeven stop
DollarTrailingAmt( .006 ), //SSP .006 or 0 if you don't want a dollar trailing stop
PctTrailingFloorAmt( .002 ), //SSP .002 or 0 here and/or in next input if you don't want a percent trailing stop or XX for XX percent
PctTrailingPct( .01 );//,// SSP .01. Enter 0 here and/or in previous input if you don't want percent trailing stop or XX for XX percent
{ ExitOnClose( false ); Turned off, not needed - Set to TRUE only for back-testing, if at all; in automated execution, the exit order will NOT be filled
at the close of the day; instead, the order can be sent into the extended session as a limit order. }

if MultiExits=true or MultiX=true then begin
if ShareOrPosition = 1 then SetStopShare else SetStopPosition;
if ProfitTargetAmt > 0 then SetProfitTarget( ProfitTargetAmt );
if StopLossAmt > 0 then SetStopLoss( StopLossAmt );
if BreakevenFloorAmt > 0 then SetBreakeven( BreakevenFloorAmt );
if DollarTrailingAmt > 0 then SetDollarTrailing( DollarTrailingAmt );
if PctTrailingFloorAmt > 0 and PctTrailingPct > 0 then SetPercentTrailing( PctTrailingFloorAmt, PctTrailingPct );
//if ExitOnClose = true then SetExitOnClose;
end;

//////////////////////////////////
////////// Hard Stop /////////////
//////////////////////////////////
Var: HardStop (false), HardStopPrice(.0004); //true to turn on, false to turn off
If HardStop = true then begin
SetStopContract;
Sell Next Bar at EntryPrice - HardStopPrice stop;
SetProfitTarget (.0007);
end;