TRADESTATION: MARCH 2013
- Details
- Parent Category: Departments
- Category: Traders' Tips
- Written by Chris Imhof

In “Camarilla Points” in this issue, author Slawomir Bobrowski describes the calculation and use of camarilla pivot values for chart analysis and trading. Bobrowski suggests that the camarilla values provide general areas of support and resistance, and he provides some trading ideas around these values.
Provided here is a function that calculates camarilla pivot values; an indicator that plots the values; and a strategy. The indicator illustrates new functionality implemented in Trade-Station 9.1, update 13, which uses a transparent plot color to eliminate connector lines when new pivot values are calculated. (See Figure 1.)

FIGURE 1: TRADESTATION. The camarilla-based indicator and strategy are applied to an hourly bar chart of $INDU with both set to three days. The use of transparent plot colors (see accompanying EasyLanguage code) eliminates the connector lines when new pivot levels are calculated.
The strategy we’re providing here is for illustrative purposes only. It has various entries and exits (both fade and trend-following) for the various camarilla levels.
To download the EasyLanguage code for the strategy, first navigate to the EasyLanguage FAQs and reference posts topic in the EasyLanguage support forum (https://www.tradestation.com/Discussions/Topic.aspx?Topic_ID=47452), scroll down, and click on the link labeled “Traders’ Tips, TASC.” Then select the appropriate link for the issue month and year. The ELD filename is “_TASC_CamarillaPoints.ELD.”
The code is also shown below.
_TASC_CamarillaPointsFunc (Function)
{ TASC Article, March, 2013 }
{ "Camarilla Points" }
{ Slawomir Bobrowski }
{ compile as integer return type }
{ see notes below for multiple output functions }
inputs:
int NumDays( numericsimple ), { pass in the number
of days to be used as the time frame for pivot
calculations; for example, if 15 is passed in,
the High/Low/Close of the last 15 days is used
for calculation of the pivot values and those
values are plotted for the next 15 days }
double oR1( numericref ),
double oR2( numericref ),
double oR3( numericref ),
double oR4( numericref ),
double oR5( numericref ),
double oS1( numericref ),
double oS2( numericref ),
double oS3( numericref ),
double oS4( numericref ),
double oS5( numericref ),
bool NewCalc( truefalseref ) ; { this input is
used to pass back (via the variable) true if
the current bar is calculating new pivot values }
variables:
bool CalcTrigger( false ),
int DayCounter( -1 ),
double RangeHigh( 0 ),
double RangeLow( 99999999999999 ),
double PeriodRange( 0 ),
double PeriodClose( 0 ),
double R1( 0 ),
double R2( 0 ),
double R3( 0 ),
double R4( 0 ),
double R5( 0 ),
double S1( 0 ),
double S2( 0 ),
double S3( 0 ),
double S4( 0 ),
double S5( 0 ) ;
{
increment day counter when a new session begins;
this calculation assumes regular session is being
used
}
if CurrentSession( 0 ) <> CurrentSession( 0 )[1] then
DayCounter += 1 ;
{ detect new time period so that new pivot
calculations can be made }
CalcTrigger = Mod( DayCounter, NumDays ) = 0
and DayCounter <> DayCounter[1] ;
if CalcTrigger then { calculate new pivot values }
begin
if DayCounter >= NumDays then { ensure there is
enough data for valid values }
begin
PeriodRange = RangeHigh - RangeLow ;
PeriodClose = Close[1] ;
{ calculate new Camarilla pivot values}
R5 = ( RangeHigh / RangeLow ) * PeriodClose ;
R4 = PeriodClose + PeriodRange * ( 1.1 ) / 2 ;
R3 = PeriodClose + PeriodRange * ( 1.1 ) / 4 ;
R2 = PeriodClose + PeriodRange * ( 1.1 ) / 6 ;
R1 = PeriodClose + PeriodRange * ( 1.1 ) / 12 ;
S1 = PeriodClose - PeriodRange * ( 1.1 ) / 12 ;
S2 = PeriodClose - PeriodRange * ( 1.1 ) / 6 ;
S3 = PeriodClose - PeriodRange * ( 1.1 ) / 4 ;
S4 = PeriodClose - PeriodRange * ( 1.1 ) / 2 ;
S5 = ( PeriodClose - ( R5 - PeriodClose ) ) ;
end ;
RangeHigh = High ;
RangeLow = Low ;
end
else if DayCounter >= 0 then
begin
if High > RangeHigh then
RangeHigh = High ;
if Low < RangeLow then
RangeLow = Low ;
end ;
{ assign reference variable values }
oR1 = R1 ;
oR2 = R2 ;
oR3 = R3 ;
oR4 = R4 ;
oR5 = R5 ;
oS1 = S1 ;
oS2 = S2 ;
oS3 = S3 ;
oS4 = S4 ;
oS5 = S5 ;
NewCalc = CalcTrigger ;
_TASC_CamarillaPointsFunc = 1 ;
{ force function to be series so that period Highs
and Lows can be tracked }
once
Value99 = R1[1] ;
{
MULTIPLE-OUTPUT FUNCTIONS
A multiple-output function has two types of parameters
or "inputs" - input parameters and input/output
parameters. The values of the input parameters are
passed into the multiple-output function, but not
modified by the function. The values of the input/
output parameters are passed into the multiple-output
function, modified by it, and the modified values
are then inherited by - or output to - the calling
routine.
The input/output parameters are often used for output
purposes only, i.e., the incoming values are ignored.
The outputs are in addition to the function return.
In multiple-output functions, the function return is
generally used to return an error code, though
sometimes the return may simply be a dummy value.
The input/output parameters are declared with a "ref"
suffix (such as "numericref") in the multiple-output
function's declaration statements. For further
clarity, the names of the input/output parameters are
generally prefixed with an "o" in the function as
well as in all the routines that call the function.
The built-in single-return WRAPPER FUNCTIONS that call
the multiple-output functions are specialized calling
routines designed to offer simplified, alternate
pathways to the functionality of the underlying
multiple-output functions. In the wrapper functions,
the input/output parameters are declared as local
variables and generally initialized to zero. They are
passed through to the multiple-output function without
further modification. After the call, the wrapper
function picks out the single output of interest and
assigns it as the return of the wrapper function.
}
_TASC_CamarillaPoints (Indicator)
{ TASC Article, March, 2013 }
{ "Camarilla Points" }
{ Slawomir Bobrowski }
{ Code works with 9.1, Update 13 and later }
inputs:
int NumDays( 15 ), { enter the number of days to
be used as the time frame for pivot
calculations; for example, if 15 is entered, the
High/Low/Close of the last 15 days is used for
calculation of the pivot values and those values
are plotted for the next 15 days }
bool PlotR1( true ), { set to true to plot R1 }
bool PlotR2( true ), { set to true to plot R2 }
bool PlotR3( true ), { set to true to plot R3 }
bool PlotR4( true ), { set to true to plot R4 }
bool PlotR5( true ), { set to true to plot R5 }
bool PlotS1( true ), { set to true to plot S1 }
bool PlotS2( true ), { set to true to plot S2 }
bool PlotS3( true ), { set to true to plot S3 }
bool PlotS4( true ),{ set to true to plot S4 }
bool PlotS5( true ) ; { set to true to plot S5 }
variables:
double R1( 0 ),
double R2( 0 ),
double R3( 0 ),
double R4( 0 ),
double R5( 0 ),
double S1( 0 ),
double S2( 0 ),
double S3( 0 ),
double S4( 0 ),
double S5( 0 ),
bool NewPeriod( false ) ;
{ obtain levels from function }
Value1 = _TASC_CamarillaPointsFunc( NumDays, R1, R2,
R3, R4, R5, S1, S2, S3, S4, S5, NewPeriod ) ;
if R1 <> 0 then { ensure values have been calculated
prior to plotting }
begin
if PlotR5 then Plot1( R5, "R5" ) ;
if PlotR4 then Plot2( R4, "R4" ) ;
if PlotR3 then Plot3( R3, "R3" ) ;
if PlotR2 then Plot4( R2, "R2" ) ;
if PlotR1 then Plot5( R1, "R1" ) ;
if PlotS1 then Plot6( S1, "S1" ) ;
if PlotS2 then Plot7( S2, "S2" ) ;
if PlotS3 then Plot8( S3, "S3" ) ;
if PlotS4 then Plot9( S4, "S4" ) ;
if PlotS5 then Plot10( S5, "S5" ) ;
end ;
{ remove connector lines when new pivot levels are
calculated; this code works in 9.1, Update 13 and
later }
if NewPeriod then
begin
SetPlotColor[1]( 1, transparent ) ;
SetPlotColor[1]( 2, transparent ) ;
SetPlotColor[1]( 3, transparent ) ;
SetPlotColor[1]( 4, transparent ) ;
SetPlotColor[1]( 5, transparent ) ;
SetPlotColor[1]( 6, transparent ) ;
SetPlotColor[1]( 7, transparent ) ;
SetPlotColor[1]( 8, transparent ) ;
SetPlotColor[1]( 9, transparent ) ;
SetPlotColor[1]( 10, transparent ) ;
end ;
_TASC_CamarillaPoints_Strat (Strategy)
{ TASC Article, March, 2013 }
{ "Camarilla Points" }
{ Slawomir Bobrowski }
{ this strategy is for illustrative purposes only and
was not designed to be traded }
[Intrabarordergeneration = true]
inputs:
int NumDays( 15 ) ; { enter the number of days to
be used as the time frame for pivot
calculations; for example, if 15 is entered, the
High/Low/Close of the last 15 days is used for
calculation of the pivot values and those values
are plotted for the next 15 days }
variables:
double R1( 0 ),
double R2( 0 ),
double R3( 0 ),
double R4( 0 ),
double R5( 0 ),
double S1( 0 ),
double S2( 0 ),
double S3( 0 ),
double S4( 0 ),
double S5( 0 ),
int DayCounter( 0 ),
bool NewPeriod( false ) ;
{ obtain levels from function }
Value1 = _TASC_CamarillaPointsFunc( NumDays, R1, R2,
R3, R4, R5, S1, S2, S3, S4, S5, NewPeriod ) ;
{ entries and exits }
if R1 > 0 then { no trades until valid calculations
are available }
begin
{ fade R3 short entry }
if Close < R3 then
SellShort ( "R3 Fade SE" ) next bar R3 Limit ;
{ fade S3 long entry }
if Close > S3 then
Buy ( "S3 Fade LE" ) next bar S3 Limit ;
{ trend trade cross S3 long entry }
if Close < S3 then
Buy ( "S3 Trend LE" ) next bar S3 stop ;
{ trend trade cross R3 short entry }
if Close > R3 then
SellShort ( "R3 Trend SE" ) next bar R3 stop ;
{ R4/S4 breakout entries }
if Close < R4 then
Buy ( "R4 BO LE" ) next bar R4 stop ;
if Close > S4 then
SellShort( "S4 BO SE" ) next bar S4 stop ;
{ long exits }
Sell ( "S3 Fade LX" ) from entry ( "S3 Fade LE" )
next bar S4 stop ;
Sell ( "S3 Trend LX" ) from entry
( "S3 Trend LE" ) next bar S4 stop ;
Sell ( "R4 BO LX Stop" ) from entry ( "R4 BO LE" )
next bar R3 stop ;
Sell ( "R4 BO LX Tgt" ) from entry ( "R4 BO LE" )
next bar R5 limit ;
{ short exits }
BuyToCover ( "R3 Fade SX" ) from entry
( "R3 Fade SE" ) next bar R4 stop ;
BuyToCover ( "R3 Trend SX" ) from entry
( "R3 Trend SE" ) next bar R4 stop ;
BuyToCover ( "S4 BO SX Stop" ) from entry
( "S4 BO SE" ) next bar S3 stop ;
BuyToCover ( "S4 BO SX Tgt" ) from entry
( "S4 BO SE" ) next bar S5 limit ;
end ;
This article is for informational purposes. No type of trading or investment recommendation, advice, or strategy is being made, given, or in any manner provided by TradeStation Securities or its affiliates.


Join us on Facebook
Follow us on Twitter