Original Camarilla EasyLanguage Code [Correction]

Camarilla – A group of confidential, often scheming advisers; a cabal.

An attentive reader of this blog, Walter Baker,  found some typos in my code.  I have corrected them in the code section – if you have used this code make sure you copy and paste the code in its entirety into your EasyLanguage editor and replace your prior version.

I wanted to elaborate on the original version of Camarilla.  The one that users have been downloading from this website is pure reversion version.  The Camarilla Equation was by created by Nick Scott, a bond day trader, in 1989.  The equation uses just yesterday’s price action to project eight support/resistance price levels onto today’s trading action.  These levels, or advisers, as the name of the equation suggests provides the necessary overlay to help predict turning points as well as break outs.  Going through many charts with the Camarilla indicator overlay it is surprising how many times the market does in fact turn at one of these eight price levels.  The equations that generate the support/resistance levels are mathematically simple:


Resistance #4 = Close + Range * 1.1 / 2;

Resistance #3 = Close + Range * 1.1/4;

Resistance #2 = Close + Range * 1.1/6;

Resistance #1 = Close + Range * 1.1/12;


Support #1 = Close – Range * 1.1/12;

Support #2 = Close – Range * 1.1/6;

Support #3 = Close – Range * 1.1/4;

Support #4 = Close – Range * 1.1/2;


The core theory behind the equation and levels is that prices have a tendency to revert to the mean.  Day trading the stock indices would be easy if price broke out and continued in that direction throughout the rest of the day.  We all know that “trend days” occur very infrequently on a day trade basis; most of the time the indices just chop around without any general direction.  This is where the Camarilla can be effective.  Take a look at the following chart [ ES 5-minute day session] where the indicator is overlaid. and how the strategy was able to take advantage of the market’s indecisiveness.  This particular example shows the counter-trend nature of the Camarilla.  The original Camarilla looked at where the market opened to make a trading decision.  The chart below is an adapted version of the one I send out when one registers on for the download.   I thought it would be a good idea to show the original that incorporates a break out along with the counter trend mechanism.  I will go over the code in the next post.  You can copy the code below and paste directly into you EasyLanguage editor.

Camarilla at its Best!
Carmarilla in Reversion Mode

Original Camarilla rules:

  • If market opens between R3 and R4 go with the break out of R4.  This is the long break out part of the strategy.
  • If market opens between R3 and S3 then counter trend trade at the R3 level.  In other words, sell short at R3.  If the market moves down, then buy S3.  As you can see this is the mean reversion portion of the strategy.
  • If market open between S3 and S4 go with the break out of S4 – the short break out method.
  • Stops are placed in the following manner:
    • If long from a R4 break-out, then place stop at R3.
    • If short from a S4 break-out, then place stop at S3.
    • If long from a R3 countertrend, then place stop at R4.
    • If short from a S3 countertrend, then place stop at S4.
  • Profit objectives can be placed at opposite resistance/support levels:
    • If short from a R3 countertrend, then take profits at S1, S2, or S3.
    • If long from a S3 countertrend, then take profits at R1, R2, or R3.

Profit objectives for all trades can be a dollar, percent of price of ATR multiple.

Example of Camarilla Break Out Trade from S4
Camarilla Break Out
inputs: endTradetime(1530);
vars: R1(0),R2(0),R3(0),R4(0),S1(0),S2(0),S3(0),S4(0),pivotPoint(0),myAvg(0);
vars: buyTrig(0),sellTrig(0),waitBar(0),s3Pen(0),r3Pen(0),s4Pen(0),r4Pen(0),s2Pen(0),r2Pen(0);
vars: buysToday(0),sellsToday(0);
vars: s3_s4(0),s2_s3(0),s1_s2(0),s4_s5(0);
vars: r1_r2(0),r2_r3(0),r3_r4(0),r4_r5(0);
vars: r1_s1(0),r3_s3(0),r4_s4(0),r5_s5(0);

if date <> date[1] then
buyTrig = 0;
sellTrig = 0;
waitBar = 0;

s3Pen = 0;
r3Pen = 0;
s4Pen = 0;
r4Pen = 0;
s2Pen = 0;
r2Pen = 0;

buysToday = 0;
sellsToday = 0;

r4_r5 = 0;
r3_r4 = 0;
r2_r3 = 0;
r1_r2 = 0;

r1_s1 = 0;
r3_s3 = 0;
r4_s4 = 0;
r5_s5 = 0;

s1_s2 = 0;
s2_s3 = 0;
s3_s4 = 0;
s4_s5 = 0;


waitBar = waitBar + 1;

R4 = CloseD(1)+(HighD(1)-LowD(1)) * 1.1 / 2;
R3 = CloseD(1)+(HighD(1)-LowD(1)) * 1.1/4;
R2 = CloseD(1)+(HighD(1)-LowD(1)) * 1.1/6;
R1 = CloseD(1)+(HighD(1)-LowD(1)) * 1.1/12;
S1 = CloseD(1)-(HighD(1)-LowD(1)) * 1.1/12;
S2 = CloseD(1)-(HighD(1)-LowD(1)) * 1.1/6;
S3 = CloseD(1)-(HighD(1)-LowD(1)) * 1.1/4;
S4 = CloseD(1)-(HighD(1)-LowD(1)) * 1.1/2;

if openD(0)<= s4 then s4_s5 = 1;

If openD(0)> s4 and openD(0) <= s3 then s3_s4 = 1;
If openD(0)> s3 and openD(0) <= s2 then s2_s3 = 1;
If openD(0)> s2 and openD(0) <= s1 then s1_s2 = 1;

If openD(0)> s1 and openD(0) <= r1 then r1_s1 = 1;

If openD(0)> r1 and openD(0) <= r2 then r1_r2 = 1;
If openD(0)> r2 and openD(0) <= r3 then r2_r3 = 1;
If openD(0)> r3 and openD(0) <= r4 then r3_r4 = 1;

If openD(0)> r4 then r4_r5 = 1;

if openD(0) < r3 and openD(0) > s3 then r3_s3 = 1;
If openD(0) < r4 and openD(0) > s4 then r4_s4 = 1;

if time < endTradeTime and time > 930 then

if r3_r4 = 1 and entriesToday(date) < 3 and c < r4 then buy("R4-BrkOut") next bar at r4 stop;
if s3_s4 = 1 and entriesToday(date) < 3 and c > s4 then sellShort("S4-BrkOut") next bar at s4 stop;

if c > r2 then r2Pen = 1;
if c > r3 then r3Pen = 1;
if c > r4 then r4Pen = 1;

if r3_s3 = 1 and r3Pen = 1 and c > r3 and entriesToday(date) < 3
then sellShort("R3Sell") next bar at r3 stop;

if r4Pen = 1 and c < r4 then r4Pen = 0;
if r3Pen = 1 and c < r3 then r3Pen = 0;
if r2Pen = 1 and c < r2 then r2Pen = 0;

if c < r1 then
r2Pen = 0;
r3Pen = 0;
r4Pen = 0;
if c > s1 then
s2Pen = 0;
s3Pen = 0;
s4Pen = 0;

if c < s2 then s2Pen = 1;
if c < s3 then s3Pen = 1;
if c < s4 then s4Pen = 1;

if r3_s3 = 1 and s3Pen = 1 and c < s3 and entriesToday(date) < 3 then
buy("S3Buy") next bar at s3 stop;

if s4Pen = 1 and c > s4 then s4Pen = 0;
if s3Pen = 1 and c > s3 then s3Pen = 0;
if s2Pen = 1 and c > s2 then s2Pen = 0;

if marketPosition = 1 then
sell from entry("S3Buy") next bar at s4 stop;
sell from entry("R4-BrkOut") next bar at r3 stop;

if marketPosition = -1 then
buyToCover from entry("R3Sell") next bar at r4 stop;
buyToCover from entry("S4-BrkOut") next bar at s3 stop;


Camarilla Strategy EasyLanguage Source

7 thoughts on “Original Camarilla EasyLanguage Code [Correction]”

  1. thank you george.
    i test it but number of contract is 100….
    i do not see how to change the quantity in the code.
    see you soon

    1. HI Jerome,

      On stocks use the keyword shares like the line below
      buy(“R4-BrkOut”) 20 shares next bar at r4 stop

      On futures you can use shares or contracts keyword.

      Or format the Strategy and click Properties for All and select the number of shares/contracts in the Trade size section there.

      Let me know if this doesn’t solve your problem.

  2. Hello, George.
    The indicator does not verify for me. I get \”position information function not allowed in a study.\”

  3. Good Morning George,

    I found this after days of searching for a way to add these pivots into tradestation. Is there any chance you\’re willing to email me the ELD? I would greatly appreciate it!

Leave a Reply