Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

TABLE OF CONTENTS

Introduction to ProBuilder_______________________________________________ Chapter I: Fundamentals_________________________________________________


Using ProBuilder................................................................................................................................... 2 Indicator creation quick tutorial....................................................................................................... 2 Programming window keyboard shortcuts......................................................................................5 Specificities of ProBuilder programming language............................................................................... !inancial constants............................................................................................................................... " Price and #olume constants adapted to the timeframe of the chart................................................" $aily price constants....................................................................................................................... % &emporal constants......................................................................................................................... % 'onstants deri#ed from price........................................................................................................ (2 &he Undefined constant................................................................................................................ (2 )ow to use pre*e+isting indicators,.................................................................................................... (2 -ariables............................................................................................................................................. (.

Chapter II : Math Functions and ProBuilder instructions_______________________


'ontrol Structures............................................................................................................................... (5 'onditional I! instruction............................................................................................................... (5 /ne condition0 one result 1I! &)23 23$I!4.............................................................................(5 /ne condition0 two results 1I! &)23 25S2 23$I!4..................................................................(5 Sequential I! conditions............................................................................................................ (5 6ultiple conditions 1I! &)23 25S2 25SI! 23$I!4...................................................................( Iterati#e !/7 5oop........................................................................................................................ (" 8scending 1!/70 &/0 $/0 329&4............................................................................................. (" $escending 1!/70 $/:3&/0 $/0 329&4...............................................................................(% 'onditional :)I52 5oop............................................................................................................... (; B728<.......................................................................................................................................... 2= :ith :)I52.............................................................................................................................. 2= :ith !/7.................................................................................................................................. 2= '/3&I3U2................................................................................................................................... 2( :ith :)I52.............................................................................................................................. 2( :ith !/7.................................................................................................................................. 2( /3'2............................................................................................................................................ 22 6athematical !unctions...................................................................................................................... 2. 'ommon unary and binary !unctions...........................................................................................2. 'ommon mathematical operators................................................................................................. 2. 'harting comparison functions...................................................................................................... 2. Summation functions.................................................................................................................... 2> Statistical functions....................................................................................................................... 2> 5ogical operators................................................................................................................................ 2> ProBuilder instructions........................................................................................................................ 2> 72&U73....................................................................................................................................... 25 726 or ??....................................................................................................................................... 25 'ustom'lose................................................................................................................................ 25 '855............................................................................................................................................. 2 8S................................................................................................................................................. 2 '/5/U72$.................................................................................................................................. 2

Chapter III : Practical aspects_____________________________________________


:hy and how to create binary or ternary indicators............................................................................2% 'reating stop indicators to follow a position.......................................................................................2; Static&ake Profit S&/P................................................................................................................. .= Static S&/P loss........................................................................................................................... .= Inacti#ity S&/P............................................................................................................................. .( &railing Stop.................................................................................................................................. .2

Chapter I : E!ercises___________________________________________________
'andlesticks patterns......................................................................................................................... .. Indicators............................................................................................................................................ .>

"lossar#______________________________________________________________

Introduction to ProBuilder

Introduction to ProBuilder
ProBuilder is Proreal&ime@s programming language. It allows you to create personaliAed technical indicators0 trading strategies 1ProBacktest4 or screening programs 1ProScreener4. 8 specific manual e+ists for ProBacktest and ProScreener due to some specifics of each of these modules.

ProBuilder is a B8SI'*type programming language0 #ery easy to handle and e+hausti#e in terms of a#ailable possibilities. Bou will be able to create your own programs using the quotes from any tool pro#ided by Pro7eal&ime. Some basic a#ailable elements includeC /pening of each bar C /pen 'losing of each bar C 'lose )ighest price of each bar C )igh 5owest price of each bar C 5ow -olume of each bar C -olume

Bars or candlesticks are the common charting representations of real time quotes. /f course0 Pro7eal&ime offers you the possibility of personaliAing the style of the chart. Bou can use 7enko0 <agi0 )aikin*8shi and many other styles. ProBuilder e#aluates the data of each price bar starting with the oldest one to the most recent one0 and then e+ecutes the formula de#eloped in the language in order to determine the #alue of the indicators on the current bar. &he indicators coded in ProBuilder can be displayed either in the price chart or in an indi#idual one.

In this document0 you will learn0 step by step0 how to use the a#ailable commands necessary to program in this language thanks to a clear theoretical o#er#iew and concrete e+amples.

In the end of the manual0 you will find a Dlossary which will gi#e you an o#erall #iew of all the ProBuilder commands0 pre*e+isting indicators and other functions completing what you would ha#e learned after reading the pre#ious parts.

Users more confident in their programming skills can skip directly to chapter II or Eust refer to the Dlossary to quickly find the information they want.

!or those who are less confident0 we recommend to watch the #ideo tutorials entitled FProgramming simple and dynamic indicatorsF and read the whole manual. -ery accurate and guiding as well as highly practically oriented0 we are certain that you will master this programming language in no time.

:ishing you the best0 good readingG

www.prorealtime.com

( ? >.

Chapter I: Fundamentals

Chapter I: Fundamentals
$sin% ProBuilder
Indicator creation &uic' tutorial &he programming Aone of an indicator is a#ailable by clicking the button FIndicator?BacktestF which can be found in the upper right corner of each graphic of the Pro7eal&ime platform.

&he indicators management window will be displayed. Bou will then be able toC $isplay a pre*e+isting indicator 'reate a personaliAed indicator0 which can be used afterwards on any security

If you choose the second possibility0 click on F3ew indicatorF to access the programming window. 8t that time0 you will be able to choose betweenC programming directly an indicator in the te+t Aone designed for writing code or use the help function by clicking on FInsert !unctionF. &his will open a new window in which you can find all the functions a#ailable. &his library is separated in " categories0 to gi#e you constant assistance while programming.

www.prorealtime.com

2 ? >.

Chapter I: Fundamentals

5etHs take for e+ample the first specific ProBuilder elementC the F (ET$(NF function 1a#ailable in the F<eywordsF category 1see the image below4.

www.prorealtime.com

. ? >.

Chapter I: Fundamentals

Select the word F(ET$(NF and click on F8ddF. &he command will be added to the programming Aone.

(ET$(N allows you to display the result

Suppose we want to create an indicator displaying the -olume. If you ha#e already inserted the function F(ET$(NF0 then you Eust need to click one more time on FInsert functionF. 3e+t0 click on F'onstantsF in the F'ategoriesF section0 then in the right side of the window0 in the section named F!unctionsF0 click on F olumeF. !inally0 click on F8ddF.

Before clicking on F-alidate programF0 you need to enter the name of your indicator. )ere0 we named it F-olume $89F. &o finish0 click on F-alidate programF and you will see your indicator displayed below the price chart.

www.prorealtime.com

> ? >.

Chapter I: Fundamentals

Pro%rammin% )indo) 'e#*oard shortcuts &he programming window has a number of useful features that can be accessed by keyboard shortcuts starting with Pro7eal&ime #ersion (= C Select all 1'trl I 84 C Select all te+t in the programming window 'opy 1'trl I '4 C 'opy the selected te+t Paste 1'trl I 94 C Paste copied te+t Undo 1'trl I J4 C Undo the last action in the programming window 7edo 1'trl I B4 C 7edo the last action in the programming window !ind ? 7eplace 1'trl I !4 C !ind a te+t in the programming window ? replace a te+t in the programming window 1this feature is case*sensiti#e4 'omment ? Uncomment 1'trl I 74 C 'omment the selected code ? Uncomment the selected code 1commented code will be preceded by F??F or F726F and colored gray. It will not be taken into account when the code is e+ecuted4. !or 6ac users0 the same keyboard shortcuts can be accessed with the F8ppleF key in place of the F'trlF key. 6ost of these features can also be accessed by right*clicking in the programming window.

www.prorealtime.com

5 ? >.

Chapter I: Fundamentals

Speci+icities o+ ProBuilder pro%rammin% lan%ua%e


Speci+icities &he ProBuilder language allows you to use many classic commands as well as sophisticated tools which are specific to technical analysis. &hese commands will be used to program from simple to #ery comple+ indicators. &he main ideas to know in the ProBuilder language areC It is not necessar# to declare ,aria*les It is not necessar# to t#pe ,aria*les &here is no di++erence *et)een capital letters and small letters 1but0 as we will see later0 there is one e+ception4 -e use the same s#m*ol ./. +or mathematic e&ualit# and to attri*ute a ,alue to a ,aria*le :hat does that mean , $eclare a #ariable 9 means indicating its e+istence. In ProBuilder0 you can directly use 9 without ha#ing to declare it. 5etHs take an e+ampleC :ith declarationC let be #ariable 90 we attribute to 9 the #alue 5 :ithout declarationC :e attribute to 9 the #alue 5 1therefore0 implicitly0 9 e+ists and the #alue 5 is attributed to it4 In ProBuilder you Eust need to writeC 9K5 &ype a #ariable means defining its nature. !or e+ampleC is the #ariable a natural number 1e+C .L %L 2(L >.L M40 a whole number which can be negati#e or positi#e 1e+C .L .2L *."L M40 a decimal number 1e+C (." >5.5.>5.5M40 a boolean 17ID)&K(0 :7/3DK=40M, In ProBuilder0 you can write your command with capital letters or small letters. !or e+ample0 the group of commands I! ? &)23 ? 25S2 ? 23$I! can be written i! ? t)e3 ? 25se ? endIf 1and many other possibilitiesG4 2+ceptionC :hen you decide to create a #ariable and re*use it later in the program0 you must not contradict the spelling you used during its creation. If you started to name your #ariableC F#87iaB5eF and wish to re*use it in your program0 then you must refer to it as F#87iaB5eF0 not as N#ariableO not anything else. 8ffect a #alue to a #ariable means gi#e the #ariable a #alue. In order to understand this principle0 you must assimilate a #ariable with an empty bo+ which you can fill with an e+pression 1e+C a number4. &he following diagram illustrate the 8ffectation 7ule with the -olume #alue affected to the #ariable 9C

olume 0 / olume

8s you can see0 we must read from right to leftC -olume is affected to 9. If you want to write it under ProBuilder0 you Eust need to replace the arrow with an equal signC

&he same K symbol is usedC !or the affectation of a #ariable 1like the pre#ious e+ample4 8s the mathematical binary operator 1(I (K 2 is equi#alent to 2 K ( I (4.
www.prorealtime.com
? >.

Chapter I: Fundamentals

Financial constants
Before coding your personal indicators0 you must e+amine the elements you need to write your code such as the opening price0 the closing price0 etc. &hese are the FfundamentalsF of technical analysis and the main things to know for coding indicators. Bou will then be able to combine them in order to draw out some information pro#ided by financial markets. :e can group them together in 5 categoriesC Price and ,olume constants adapted to the time+rame o+ the chart &hese are the FclassicalF constants and also the ones used the most. &hey report by default the #alue of the current bar 1whate#er the timeframe used4. Open : /pening price of each bar 1i%h : )ighest price of each bar Lo) : 5owest price of each bar Close : 'losing price of each bar olume : &he number of securities or contracts e+changed at each bar

E!ample : 7ange of the current bar


a = High b = Low MyRange = a - b RETURN MyRange

If you want to use the information of pre#ious bars rather than the current bar0 you Eust need to add between square brackets the number of bars that you want to go back into the past. Lets take for example the closing price constant: Value of the closing price of the current bar: Value of the closing price preceding the current bar: Value of the closing price preceding the nth bar preceding the current one: Close Close[1] Close [n]

&his rule is #alid for any constant. !or e+ample0 the opening price of the 2nd bar preceding the current can be e+pressed asC /penP2Q. &he reported #alue will depend on the displayed timeframe of the chart.
www.prorealtime.com
" ? >.

Chapter I: Fundamentals

2ail# price constants 'ontrary to the constants adapted to the timeframe of the chart0 the daily price constants refer to the #alue of the day0 regardless the timeframe of the chart. 8nother difference between $aily price constants and constants adapted to the timeframe of the chart is that the daily price constants use brackets and not square brackets to call the #alues of pre#ious bars. 2Open3n4 : /pening price of the nth day before the one of the current bar 21i%h3n4 : )ighest price of the nth day before the one of the current bar 2Lo)3n4 : 5owest price of the nth day before the one of the current bar 2Close3n4 : 'losing price of the nth day before the one of the current bar 3oteC FnF can be equal to = if we want to call the #alue for today as shown in the e+ample below. $ay*traders know the importance of the close of the day before and of the open that is a moment of emotion when the no#ices enter or e+it the market. &he high and low of the pre#ious days can indicate the price changes of the ne+t day. E!ample : $aily 7ange
a = DHigh(0) b = DLow(0) MyRange = a - b RETURN MyRange

&he constants adapted to the timeframe of the chart use square brackets while the daily price constants use brackets. 'loseP.Q &he closing price . periods ago $close1.4 &he closing price . days ago

Temporal constants &ime is often a neglected component of technical analysis. )owe#er traders know #ery well the importance of some time periods in the day or dates in the year. It is possible in your programs to take into account time and date and impro#e the efficiency of your indicators. &he &emporal constants are described hereafterC 2ate : indicates the date of the close of each bar in the format Bear6onth$ay 1BBBB66$$4 &emporal constants are considered by ProBuilder as whole numbers. &he $ate constant0 for e+ample0 must be used as one number made up of % figures. 5etHs write down the programC
RETURN Date

Suppose today is the >th of Ruly 2==%0 the program abo#e will return the #alue 2==%="=> for today and 2==%="=. for yesterday and so on for pre#ious days. $ate under ProBuilder is then based on the following scale of #alueC /ne millennium is equi#alent to (= === === date units /ne century is equi#alent to ( === === date units /ne decade is equi#alent to (== === date units /ne year is equi#alent to (= === date units &en months are equi#alent to ( === date units 1do not e+ceed (2 months4 /ne month is equi#alent to (== date units 1do not e+ceed (2 months4 &en days are equi#alent to(= date units 1do not e+ceed .( seconds4 /ne day is equi#alent to ( date unit 1do not e+ceed .( seconds4
www.prorealtime.com
% ? >.

Chapter I: Fundamentals

Time : indicates the hour of the closing price of each bar in the format )our6inuteSecond 1))66SS4 2+ampleC
RETURN Time

&his indicator shows us the closing time of each bar in the format ))66SSC

It is also possible to use Time and 2ate in the same indicator to do analysis or display results at a precise moment. In the following e+ample0 we want to limit our indicator to the date of /ctober (st at precisely ;am and ( secondC
a = (Date = 20081001) b = (Time = 090001) RETURN (a ND b)

Similar to $ate0 &ime uses the following scale of #alueC &en hours are equi#alent to (== === time units 1do not e+ceed 2. hours4 /ne hour is equi#alent to (= === units 1do not e+ceed 2. hours4 &en minutes are equi#alent to ( === time units 1do not e+ceed 5; minutes4 /ne minute is equi#alent to (== time units 1do not e+ceed 5; minutes4 &en seconds are equi#alent to (= time units 1do not e+ceed 5; seconds4 /ne second is equi#alent to ( time unit 1do not e+ceed 5; seconds4 &he following constants work the same wayC Minute : 6inute of the close of each bar 1from = to 5;4C /nly for intraday charts. 1our : )our of the close of each bar 1from = to 2.4C /nly for intraday charts. 2a# : $ay of the months of the closing price of each bar 1from ( to 2% or 2; or .= or .(4 Month : 6onth of the closing price of each bar 1from ( to (24 5ear : Bear of the closing price of each bar 2a#O+-ee' : $ay of the :eek of the close of each bar 1does not use weekend days4 1(K6onday0 2K&uesday0 .K:ednesday0 >K&hursday0 5K!riday4 2+ampleC
a = (Ho!" # 1$0000) b = (Day = %0) RETURN (a ND b) www.prorealtime.com
; ? >.

Chapter I: Fundamentals

Current1our : 'urrent )our 1of the local market4 CurrentMinute : 'urrent 6inute 1of the local market4 CurrentMonth : 'urrent 6onth 1of the local market4 CurrentSecond : 'urrent Second 1of the local market4 Toda# : 'urrent $ate 1of the local market4 CurrentTime : 'urrent )our6inuteSecond 1of the local market4 Current5ear : 'urrent Bear 1of the local market4 Current2a#O+-ee' : 'urrent $ay of the week with the market time Aone as a reference The di++erence between the F'urrentF constants and the Fnon*'urrentF constants presented abo#e is the F'urrentF aspect. &he following picture brings to light that difference 1applied on the CurrentTime and Time constants4. :e can highlight the fact that for F'urrentF constants0 we must set aside the time a+is and only take in consideration the displayed #alue 1the #alue of the current time is displayed o#er the whole history of the chart4.

Time indicates the closing time of each bar. CurrentTime indicates the current market time. If you want to set up your indicators with counters 1number of days passed0 number of bars passed etcM40 you can use the 2a#s0 BarInde! and Intrada#BarInde! constants. 2a#s : 'ounter of days since (;== &his constant is quite useful when you want to know the number of days that ha#e passed. It is particularly rele#ant when you work with an 1+4 tick or 1+4 #olume #iew. &he following e+ample shows you the number of days passed since (;==.
RETURN Day& www.prorealtime.com
(= ? >.

Chapter I: Fundamentals

BarInde! : 'ounter of bars since the beginning of the displayed historical data &he counter starts from left to right and counts each bar0 including the current bar. &he first bar loaded is considered bar number =. 6ost of the time0 BarInde! is used with the IF instruction presented later in the manual.

Intrada#BarInde! : 'ounter of intraday bars &he counter displays the number of bars since the beginning of the day and then resets to Aero at the beginning of e#ery new day. &he first bar of the counter is considered bar number =.

5etHs compare the two counter constants with two separated indicatorsC
RETURN 'a"(n)e*

and
RETURN (nt"a)ay'a"(n)e*

:e can clearly see the difference between themC Intrada#BarInde! reset itself to Aero at the beginning of e#ery new day.

www.prorealtime.com

(( ? >.

Chapter I: Fundamentals

Constants deri,ed +rom price &hese constants allows you to get more complete information compared to Open0 1i%h0 Lo) and Close0 since they combine those prices so to emphasiAe some aspects of the financial market psychology shown on the current bar. (an%e : difference between )igh and 5ow. T#picalPrice : a#erage between )igh0 5ow and 'lose -ei%htedClose : weighted a#erage of )igh 1weight (40 5ow 1weight (4 and 'lose 1weight 24 MedianPrice : a#erage between )igh and 5ow TotalPrice : a#erage between /pen0 )igh0 5ow and 'lose 5e (an%e shows the #olatility of the current bar0 which is an estimation of how ner#ous in#estors are. Bou can create an indicator with one of the constants abo#e only by creating a one*line indicator F72&U73 7angeF for e+ample or use the constants to create a more complicated indicator. &he -ei%htedClose focuses on the importance of the closing price bar 1e#en more important when applied to daily bars or weekly bars4. &he T#picalPrice and TotalPrice emphasiAe intraday financial market psychology since they take . or > predominant prices of the current bar into account 1see abo#e4. MedianPrice uses the 6edian concept 1the middle number4 instead of the 8#erage concept which is quite useful when trying to create theoretical models that donHt take in#estors psychology into account. (an%e in 6 :
MyRange = Range +a,-!, = (MyRange . MyRange/10 - 1) 1 100 RETURN +a,-!,

The $nde+ined constant &he keyword $nde+ined allows you to indicate to the software not to display the #alue of the indicator. $nde+ined : undefined data 1equi#alent to an empty bo+4 Bou can find an e+ample later in the manual.

1o) to use pre7e!istin% indicators8


Up until now0 we ha#e described you the possibilities offered by ProBuilder concerning constants and how to call #alues of bars of the past using these constants. Pre*e+isting indicators 1the ones already programmed in Pro7eal&ime4 function the same way and so do the indicators you will code. ProBuilder indicators are made up of three elements which synta+ isC NameO+Function 9calculated o,er n periods: 3applied to )hich price or indicator4 :hen using the FInsert !unctionF button to look for a ProBuilder function and then enter it into your program0 default #alues are gi#en for both the period and the price or indicator argument.

A,era%e9;<:3Close4
:e can of course modify these #alues according to our preferencesL for e+ample0 we can replace the 2= bars defined by default with (== bars. In the same way0 we can change the price argument F'loseF with F/penF or F2Open3=4F S the open of the daily bar days agoC

A,era%e9;<:32open3=44
www.prorealtime.com
(2 ? >.

Chapter I: Fundamentals

)ere are some sample programsC Pro%ram calculatin% the e!ponential mo,in% a,era%e o,er ;< periods applied to the closin% price:
RETURN E*2onentia, 3e"age/200(+,o&e)

Pro%ram calculatin% the )ei%hted mo,in% a,era%e o,er ;< *ars applied to the t#pical price
mm = 4eighte) 3e"age/200(Ty2i-a,5"i-e) RETURN mm

Pro%ram calculatin% the -ilder a,era%e o,er ><< candlestic's applied to the olume
mm = 4i,)e" 3e"age/1000(6o,!me) RETURN mm

Program calculating the 68'$ 1histogram4 applied to the closing price. &he 68'$ is built with the difference between the (2*period e+ponential mo#ing a#erage 12684 minus the 2 *period 268. &hen0 we make a smoothing with an e+ponential mo#ing a#erage o#er ; periods and applied to the 68'$ line to get the Signal line. !inally0 the 68'$ is the difference between the 68'$ line and the Signal line.
REM +a,-!,ation o7 the M +D ,ine M +DLine = E*2onentia, 3e"age/120(+,o&e) - E*2onentia, 3e"age/280(+,o&e) REM +a,-!,ation o7 the M +D 9igna, ,ine M +D9igna,Line = E*2onentia, 3e"age/90(M +DLine) REM +a,-!,ation o7 the )i77e"en-e between the M +D ,ine an) it& 9igna, M +DHi&tog"amme = M +DLine : M +D9igna,Line RETURN M +DHi&tog"amme

aria*les
:hen you code an indicator0 you may want to introduce #ariables. &he #ariables option in the upper* right corner of the window allows you to attribute a default #alue to an undefined #ariable and manipulate it in the FsettingsF window of the indicator without modifying the code of your program. 5etHs calculate a simple mo#ing a#erage on 2= periodsC
RETURN 3e"age/200(+,o&e)

www.prorealtime.com

(. ? >.

Chapter I: Fundamentals

In order to modify the number of periods for the calculation directly from the indicator FSettingsF interface0 replace 2= with the #ariable FnFC
RETURN 3e"age/n0(+,o&e)

&hen0 click on F8ddF in F-ariablesF and another window named F-ariable definitionF will be displayed. !ill it in as followsC

'lick on the F/<F button. &hen0 in the FSettingsF window 1in this case FSettings 6y6o#ing8#erageF4 you will see a new parameter which will allow you to modify the number of periods in the calculation of the mo#ing a#erageC

/f course0 it is possible to do the same with many #ariables gi#ing you the possibility to manipulate multiple parameters at the same time for the same indicator.

www.prorealtime.com

(> ? >.

Chapter II : Math Functions and ProBuilder instructions

Chapter II : Math Functions and ProBuilder instructions


Control Structures
Conditional IF instruction &he IF instruction is used to make a conditioned action0 meaning e+ecuting the action if one or more conditions is met. &he structure is made up of the instructions IF0 T1EN0 ELSE0 ELSIF0 EN2IF0 which are used depending on the comple+ity of the conditions you defined.
One condition? one result 3IF T1EN EN2IF4

:e can look for a condition and define an action if that condition is true. /n the other hand0 if the condition is not #alid0 then nothing will happen 1By default0 7esult K =4. In this e+ample0 if current price is greater than the 2=*period mo#ing a#erage0 then we displayC 7esult K ( and display this on the chart.
(; +,o&e # END(; RETURN Re&!,t 3e"age/200(+,o&e) THEN I! Price T 2=*period mo#ing a#erage then Re&!,t = 1

7esult K (0 otherwise 7esult K= end of the I! condition $isplay the #alue of result on the chart

(ET$(N must always be followed with the storage #ariable containing the result in order to display the result on the chart 1in the last e+ample we use the #ariable F7esultF4.
One condition? t)o results 3IF T1EN ELSE EN2IF4

:e can also define a different result if the condition is not true. 5et us go back to the pre#ious e+ampleC if the price is greater than the mo#ing a#erage on 2= periods0 then display (0 else0 displays *(.
(; +,o&e # 3e"age/200(+,o&e) THEN Re&!,t = 1 EL9E Re&!,t = -1 END(; RETURN Re&!,t

NB: e ha!e created a binar" indicator# $or more information% see the section on binar" and ternar" indicators later in this manual#
Se&uential IF conditions

Bou can create sub*conditions after the #alidation of the main condition0 meaning conditions which must be #alidated one after another. !or that0 you need to build a sequence of IF structures0 one included in the other. Bou should be careful to insert in the code as many EN2IF as IF. 2+ampleC 2ou*le conditions on mo,in% a,era%es :
(; ( 3e"age/120(+,o&e) - 3e"age/200(+,o&e) # 0) THEN (; E*2onentia, 3e"age/120(+,o&e) - E*2onentia, 3e"age/200(+,o&e) # 0 THEN Re&!,t = 1 EL9E Re&!,t = -1 END(; END(; RETURN Re&!,t www.prorealtime.com
(5 ? >.

Chapter II : Math Functions and ProBuilder instructions

Multiple conditions 3IF T1EN ELSE ELSIF EN2IF4

Bou can define a specific result for a specific condition. &he indicator reports many statesC if 'ondition ( is #alid then do 8ction(L else0 if 'ondition 2 is #alid0 then do 8ction 2 Mif none of the pre#iously mentioned conditions are #alid then do 8ction n. &his structure uses the following instructionsC IF0 T1EN0 ELSIF0 T1EN.... ELSE0 EN2IF. &he synta+ is C
(; (+on)ition1) THEN ( -tion1) EL9(; (+on)ition2) THEN ( -tion2) EL9(; (+on)ition%) THEN ( -tion%) <<< <<< <<< EL9E ( -tion n) END(;

Bou can also replace ELSIF with ELSE IF but your program will take longer to write. /f course0 you will ha#e to end the loop with as many instance of EN2IF as IF. If you want to make multiple conditions in your program0 we ad#ise you to use ELSIF rather than ELSE IF for this reason. E!ample: detection of bearish and bullish engulfing lines using the 2lsif instruction &his indicator displays ( if a bullish engulfing line is detected0 *( if a bearish engulfing line is detected0 and = if neither of them is detected.
.. Dete-tion +on)ition1 = +on)ition2 = +on)ition% = +on)ition? = o7 a b!,,i&h eng!,7ing ,ine +,o&e/10 = >2en/10 >2en = +,o&e/10 +,o&e # >2en/10 >2en = +,o&e

.. Dete-tion +on)ition@ = +on)ition8 = +on)ition$ = +on)ition8 =

o7 a bea"i&h eng!,7ing ,ine +,o&e/10 # >2en/10 +,o&e = >2en >2en # +,o&e/10 +,o&e = >2en/10

(; +on)ition1 ND +on)ition2 ND +on)ition% ND +on)ition? THEN a = 1 EL9(; +on)ition@ ND +on)ition8 ND +on)ition$ ND +on)ition8 THEN a = -1 EL9E a = 0 END(; RETURN a

www.prorealtime.com

( ? >.

Chapter II : Math Functions and ProBuilder instructions

E!ample: 7esistance $emarks pi#ot


(; D+,o&e(1) # D>2en(1) THEN 5high = DHigh(1) A (D+,o&e(1) - DLow(1)) . 2 5,ow = (D+,o&e(1) A DLow(1)) . 2 EL9(; D+,o&e(1) = D>2en(1) THEN 5high = (DHigh(1) A D+,o&e(1)) . 2 5,ow = DLow(1) - (DHigh(1) - D+,o&e(1)) . 2 EL9E 5high = D+,o&e(1) A (DHigh(1) - DLow(1)) . 2 5,ow = D+,o&e(1) - (DHigh(1) - DLow(1)) . 2 END(; RETURN 5high B 5,ow

E!ample: BarInde+ In the chapter I of our manual0 we presented BarInde! as a counter of bars loaded. BarInde! is often used with IF. !or e+ample0 if we want to know if the number of bars in your chart e+ceeds 2. bars0 then we will writeC
(; 'a"(n)e* == 2% THEN a = 0 EL9(; 'a"(n)e* # 2% THEN a = 1 END(; RETURN a

Iterati,e FO( Loop FO( is used when we want to e+ploit a finite series of elements. &his series must be made up of whole numbers 1e+C (0 20 .0 etcM4 and ordered. Its structure is formed of FO(0 TO0 2O-NTO0 2O0 NE0T. TO and 2O-NTO are used depending on the order of appearance in the series of the elements 1ascending order or descending order4. :e also highlight the fact that what is between FO( and 2O are the e+tremities of the inter#al to scan.
Ascendin% 3FO(? TO? 2O? NE0T4
;>R (6a"iab,e = 'eginning6a,!e>7The9e"ie&) T> En)ing6a,!e>7The9e"ie& D> ( -tion) NECT

E!ample: Smoothing of a (2*period mo#ing a#erage 5etHs create a storage #ariable 17esult4 which will sum the ((0 (2 and (.*period mo#ing a#erages.
Re&!,t = 0 ;>R 6a"iab,e = 11 T> 1% D> Re&!,t = 3e"age/6a"iab,e0(+,o&e) A Re&!,t NECT REM LetD& -"eate a &to"age 3a"iab,e ( 3e"ageRe&!,t) whi-h wi,, )i3i)e Re&!,t by % an) )i&2,ay a3e"age "e&!,t< 3e"age "e&!,t i& a &moothing o7 the 12-2e"io) mo3ing a3e"age< 3e"ageRe&!,t = Re&!,t . % RETURN 3e"ageRe&!,t www.prorealtime.com

(" ? >.

Chapter II : Math Functions and ProBuilder instructions

5etHs see step by step how the program does the calculationC 6athematically0 we want to calculate the a#erage of the mo#ing a#erages calculated on ((0 (2 and (. periods. Period will then get successi#ely the #alues ((0 (2 and (. 1!/7 always works with whole numbers only4. 7esult K = :hen Period K (( C &he new 7esult K the (( * period mo#ing a#erage I the pre#ious #alue of result 1=4. &he counter recei#es its ne+t #alue :hen Period K (2 C &he new 7esult K the (2 * period mo#ing a#erage I the pre#ious #alue of result. &he counter recei#es its ne+t #alue :hen Period K (. C &he new 7esult K the (. * period mo#ing a#erage I the pre#ious #alue of result. (. is the last #alue of the counter. :e end the NFO(O loop with the NNE0TO instruction. :e then display 8#erage7esult &o sum it up0 #ariable will0 first of all0 get the beginning #alue of the series0 then #ariable will recei#e the ne+t one 1the last one I (4 and so on until the #ery last #alue of the series. &o finish0 we end the loop. E!ample: 8#erage of the highest price o#er the 2= last bars
M high = 0 9UMhigh = 0

If there are not yet 2= periods displayed &hen we attribute to 68high #alue FUndefinedF 1not displayed4 EL9E 25S2 ;>R i = 0 T> 20 D> !/7 #alues of i between ( to 2= 9UMhigh = High/i0A9UMhigh :e sum the 2= last F)ighF #alues
(; 'a"(n)e* = 20 THEN M high = Un)e7ine) NECT END(; M high = 9UMhigh . 20 RETURN M high

:e calculate the a#erage for the last 2= periods and store the result in 68high :e display 68high

2escendin% 3FO(? 2O-NTO? 2O? NE0T4 &o make a descending loop0 we useC FO(0 2O-NTO0 2O0 NE0T.

Its synta+ isC


;>R (6a"iab,e = En)ing6a,!e>7The9e"ie&) D>4NT> 'eginning6a,!e>7The9e"ie& D> ( -tion) NECT

5et us go back to the pre#ious e+ample 1the 2=*period mo#ing a#erage of F)ighF4 C :e can notice that we ha#e Eust in#erted the e+tremities of the scanned inter#al.
M high = 0 9UMhigh = 0 (; 'a"(n)e* = 0 THEN M high = Un)e7ine) EL9E ;>R i = 20 D>4NT> 1 D> 9UMhigh = High/i0 A 9UMhigh NECT END(; M high = 9UMhigh . 20 RETURN Mmhigh www.prorealtime.com
(% ? >.

Chapter II : Math Functions and ProBuilder instructions

Conditional -1ILE Loop -1ILE is used to keep doing an action while a condition remains true. Bou will see that this instruction is #ery similar to the simple conditional instruction IF?T1EN?EN2IF. &his structure uses the following instructionsC -1ILE0 12O optional40 -EN2 1end -1ILE4 Its synta+ isC
4H(LE (+on)ition) D> ( -tion 1) E ( -tion n) 4END

E!ample:
Re&!,t = 0 4H(LE +,o&e # Re&!,t = 1 4END RETURN Re&!,t 3e"age/200(+,o&e) D>

E!ample: indicator calculating the number of consecuti#e increases


(n-"ea&e = (+,o&e # +,o&e/10) +o!nt = 0 4H(LE (n-"ea&e/+o!nt0 D> +o!nt = +o!nt A 1 4END RETURN +o!nt

&eneral comment on the conditional instruction WHILE 'imilarl" to IF% the program (ill not process the conditional loop if the condition is unkno(n# For e!ample:
+o!nt = 0 4H(LE i =# 11 D> i = i A 1 +o!nt = +o!nt A 1 4END RETURN +o!nt

5Hinstruction -1ILE ne connaUt pas la #aleur dHorigine de i donc ne peut pas tester si i est bien Vgal W (=. &he -1ILE instruction does not recogniAe the #alue of i. &herefore0 it cannot test whether i is equal to (= or not and the loop will not be processed0 hence the count is equal to =. &he correct code would beC
i = 0 +o!nt = 0 4H(LE i =# 11 D> i = i A 1 +o!nt = +o!nt A 1 4END RETURN +o!nt

In this code0 i is initialiAed. &he loop will then work correctly since the condition for beginning the loop is #alid.
www.prorealtime.com
(; ? >.

Chapter II : Math Functions and ProBuilder instructions

B(EA@ &he B(EA@ instruction allows you to make a forced e+it out of a -1ILE loop or a FO( loop. 'ombinations are possible with the IF command0 inside a -1ILE loop or a FO( loop.
-ith -1ILE

:hen we try to get out of a conditional -1ILE loop without waiting for a situation where the condition is not #alid0 we use B(EA@. Its synta+ isC
4H(LE (+on)ition) D> ( -tion) 'RE F 4END

5etHs take for e+ample an indicator showing increases of the priceC


REM T"en) in)i-ato"G in)i-ate& in-"ea&e& REM 4hen the in)i-ato" i& eH!a, to 1 then an in-"ea&e i& )ete-te)B e,&eB the in)i-ato" i& eH!a, to 0< (n-"ea&e = (+,o&e - +,o&e/10) # 0 (n)i-ato" = 0 i = 0 4H(LE (n-"ea&e/i0 D> (n)i-ato" = (n)i-ato" A 1 i = i A 1 'RE F 4END RETURN (n)i-ato"

In this code0 if B(EA@ wasnHt used0 the loop would ha#e resumed and the result would be another trend indicator which would ha#e cumulated increases.
-ith FO(

:hen we try to get out of an iterati#e FO( loop0 without reaching the last 1or first4 #alue of the series0 we use B(EA@.
;>R (6a"iab,e = 'eginning6a,!e>7The9e"ie&) T> En)ing6a,!e>7The9e"ie& D> ( -tion) 'RE F NECT

5etHs take for e+ample an indicator cumulating increases of the #olume of the last (; periods. &his indicator will be equal to = if the #olume decreases.
+o!nt = 0 ;>R i = 0 T> 19 D> (; (6o,!me/i0 # 6o,!me/i A 10) THEN +o!nt = +o!nt A 1 EL9E 'RE F END(; NECT RETURN +o!nt

In this code0 if B(EA@ werenHt used0 the loop would ha#e continued until (; 1last element of the series4 e#en if the condition count is not #alid. )owe#er0 with B(EA@0 as soon as the condition is #alid0 the result becomes =.

www.prorealtime.com

2= ? >.

Chapter II : Math Functions and ProBuilder instructions

CONTIN$E &he CONTIN$E instruction allows you to resume the program reader at the line where -1ILE or FO( is written0 thus without restarting completely the loop 1any incremented counter will thus keep its #alue and not be reset to =4. &his command is often used with B(EA@0 either to lea#e the loop 1B(EA@4 or to stay in the loop 1CONTIN$E4.

-ith -1ILE

5etHs create a program counting the number of candlesticks whose close and open are greater than those of the candlestick preceding them. If the condition is not #alid0 then the counter will be reset to =.
(n-"ea&e = +,o&e # +,o&e/10 +o!nt = 0 4H(LE >2en = >2en/10 D> (; (n-"ea&e/+o!nt0 THEN +o!nt = +o!nt A 1 +>NT(NUE END(; 'RE F 4END RETURN +o!nt

:hen using CONTIN$E0 if the IF condition is not #alid0 then the -1ILE loop is not ended. &his allows us to count the number of patterns detected with this condition. :ithout the CONTIN$E instruction0 the program would lea#e the loop0 e#en if the IF condition is #alidated. &hen0 we would not be able to continue counting the number of patterns detected and the result would be binary 1(0 =4.

-ith FO(

5etHs create a program counting the number of candlesticks whose close and open are greater than those of the candlestick preceding them. If the condition is not #alid0 then the counter will be reset to =.
(n-"ea&e = +,o&e # +,o&e/10 +o!nt = 0 ;>R i = 1 T> 'a"(n)e* D> (; (n-"ea&e/+o!nt0 THEN +o!nt = +o!nt A 1 +>NT(NUE END(; 'RE F NECT RETURN +o!nt

FO( gi#es you the possibility to test the condition o#er all the data loaded. :hen used with CONTIN$E0 if the IF condition is #alidated0 then we do not lea#e the FO( loop and resume it with the ne+t #alue of i. &his is how we count the number of patterns detected by this condition. :ithout CONTIN$E0 the program would lea#e the loop0 e#en if the IF condition is #alidated. &hen0 we would not be able to count the number of patterns detected and the result would be binary 1(0 =4.

www.prorealtime.com

2( ? >.

Chapter II : Math Functions and ProBuilder instructions

ONCE &he ONCE instruction is used to initialiAe a #ariable at a certain #alue F onl# ONE TIMEF. <nowing that for the whole program0 the language will read the code for each bar displayed on the chart before returning the result0 you must then keep in mind that ONCE C Is processed only one time by the program including the second reading. $uring the second reading of the program0 it will stock the #alues calculated in the pre#ious reading.

To +ull# understand ho) this command )or's? #ou need to percei,e ho) the lan%ua%e processes the code? hence the use+ulness o+ the ne!t e!ampleA

&hese are two programs returning respecti#ely = and (5 and which only difference is the ONCE command addedC Pro%ram >
1 2 % ? @ 8 $ +o!nt = 0 i = 0 (; i == @ THEN +o!nt = +o!nt A i i = i A 1 END(; RETURN +o!nt 1 2 % ? @ 8 $

Pro%ram ;
>N+E +o!nt = 0 >N+E i = 0 (; i == @ THEN +o!nt = +o!nt A i i = i A 1 END(; RETURN +o!nt

LetBs see ho) the lan%ua%e read the codeA Pro%ram > : !or the first bar0 the language will read line ( 15(C 'ount K =L i K =40 then 520 5.0 5>0 55 and 5 1'ount K =L i K (4. !or the ne+t bar0 the program starts at the beginning and both i and count are set to =0 so count will always return = for e#ery bar.

Pro%ram ; : !or the first bar0 the language will read 5( 1'ount K =L i K =40 then 520 5.0 5>0 550 5 1'ount K =L i K (4. :hen it arri#es at the line F(ET$(NF0 it restarts the loop to calculate the #alue of the ne+t bar starting from 5. 1the lines )ith ONCE are processed onl# one time 40 5>0 550 5 1'ount K (L i K 240 then go back again 1'ount K .L i K .4 and so forth to 1'ount K (5L i K 4. 8rri#ed at this result0 the IF loop is not processed anymore because the condition is not #alid anymoreL the only line left to read is 5"0 hence the result is (5 for the remaining bars loaded.

www.prorealtime.com

22 ? >.

Chapter II : Math Functions and ProBuilder instructions

Mathematical Functions
Common unar# and *inar# Functions 5etHs focus now on the 6athematical !unctions. Bou will find in ProBuilder the main functions known in mathematics. Please note that a and b are e+amples and can be numbers or any other #ariable in your program. MIN1a0 b4 C calculate the minimum of a and b MA01a0 b4 C calculate the ma+imum of a and b (O$N21a4 C round a to the nearest whole number ABS1a4 C calculate the absolute #alue of a S"N1a4 C shows the sign of a 1( if positi#e0 *( if negati#e4 SC$A(E1a4 C calculate a squared SC(T1a4 C calculate the square root of a LO"1a4 C calculate the 3eperian logarithm of a E0P1a4 C calculate the e+ponent of a COS1a4 C calculate the cosine of a SIN1a4 C calculate the sine of a TAN1a4 C calculate the tangent of a ATAN1a4 C calculate the arc*tangent of a

5etHs code the e+ample of the normal distribution in mathematics. ItHs interesting because it use the square function0 the square root function and the e+ponential function at the same timeC
REM No"ma, Law a22,ie) to * = 10B 9tan)a")De3iation = 8 an) MathE*2e-tation = 8 REM LetD& )e7ine the 7o,,owing 3a"iab,e& in the 3a"iab,e o2tionG 9tan)a")De3iation = 8 MathE*2e-tation = 8 * = 10 (n)i-ato" = EC5((1 . 2) 1 (9IU RE(* - MathE*2e-tation) . 9tan)a")De3iation)) . (9tan)a")De3iation 1 9IRT(2 . %<1?)) RETURN (n)i-ato"

Common mathematical operators a D * : a is strictly less than b a D/ * or a /D * : a is less than or equal to b a E * : a is strictly greater than b a E/ * or a /E * : a is greater than or equal to b a / * : a is equal to b 1or b is attributed to a4 a DE * : a is different from b

Chartin% comparison +unctions a C(OSSES O E( * : the a cur#e crosses o#er the b cur#e a C(OSSES $N2E( * : the a cur#e crosses under the b cur#e
www.prorealtime.com
2. ? >.

Chapter II : Math Functions and ProBuilder instructions

Summation +unctions cumsum : 'alculates the sum of a price or indicator o#er all bars loaded on the chart &he synta+ of cumsum isC
-!m&!m (2"i-e o" in)i-ato")

2+ C -!m&!m(+,o&e) calculates the sum of the close of all the bars loaded on the chart. summation : 'alculates the sum of a price or indicator o#er the last n bars &he sum is calculated starting from the most recent #alue 1from right to left4 &he synta+ of summation isC
&!mmation/n!mbe" o7 ba"&0(2"i-e o" in)i-ato")

2+C &!mmation/200(>2en) calculates the sum of the open of the last 2= bars. Statistical +unctions &he synta+ of all these functions is the same as the synta+ for the Summation function0 that isC
,owe&t/n!mbe" o7 ba"&0(2"i-e o" in)i-ato")

lo)est : displays the lowest #alue of the price or indicator written between brackets0 o#er the number of periods defined hi%hest : displays the highest #alue of the price or indicator written between brackets0 o#er the number of periods defined ST2 : displays the standard de#iation of a price or indicator0 o#er the number of periods defined STE : displays the standard error of a price or indicator0 o#er the number of periods defined

Lo%ical operators
8s any programming language0 it is necessary to ha#e at our disposal some 5ogical /perators to create rele#ant indicators. &hese are the > 5ogical /perators of ProBuilderC NOT1a4 C logical 3/ a O( b C logical /7 a AN2 b C logical 83$ a 0O( b C e+clusi#e /7 Calculation o+ the trend indicator: On Balance olume 3OB 4 :
(; N>T((+,o&e # +,o&e/10) >R (+,o&e = +,o&e/10)) THEN My>'6 = My>'6 - 6o,!me EL9E My>'6 = My>'6 A 6o,!me END(; RETURN My>'6

ProBuilder instructions
(ET$(N : displays the result CustomClose : displays a customiAable price #alueL by default0 this price is F'loseF CALL : calls another ProBuilder indicator to use in your current program AS : names the result displayed COLO$(E2 : colors the displayed cur#e in with the color of your choice
www.prorealtime.com
2> ? >.

Chapter II : Math Functions and ProBuilder instructions

(ET$(N :e ha#e already seen in chapter I how important the (ET$(N instruction was. It has some specific properties we need to know to a#oid programming errors. &he main points to keep in mind when using (ET$(N in order to write a program correctly are that 7eturn is usedC /ne and only one time in each ProBuilder program 8lways at the last line of code /ptionally with other functions such as 8S and '/5/U72$ &o display many resultsL we write 72&U73 followed with what we want to display and separated with a comma 1e+ample C 72&U73 a0b4 (EM or FF (EM allows you to write remarks or comments inside the code. &hey are mainly useful to remember how a function you coded works. &hese remarks will be read but of course not processed by the program. 5etHs illustrate the concept with the following e+ample C
REM Thi& 2"og"am "et!"n& the &im2,e mo3ing a3e"age o3e" 20 2e"io)& a22,ie) to the -,o&ing 2"i-e RETURN 3e"age/200(+,o&e)

$onXt use special characters 1e+amplesC V0Y0Z0[M4 in ProBuilder0 e#en in the (EM section CustomClose CustomClose is a constant allowing you to display the Close0 Open0 1i%h0 Lo) constants and many others0 which can be customiAed in the Settings window of the indicator. Its synta+ is the same as the one of the constants adapted to the timeframe of the chartC
+!&tom+,o&e/n0

2+ampleC
.. Di&2,ay& the a3e"age o3e" 20 2e"io)& a22,ie) to +!&tom+,o&e RETURN +!&tom+,o&e/20

By clicking on the wrench in the upper left corner of the chart0 you will see that it is possible to customiAe the prices used in the calculation 1on the diagram0 circled in yellow4.

www.prorealtime.com

25 ? >.

Chapter II : Math Functions and ProBuilder instructions

CALL CALL allows you to use a personal indicator you ha#e coded before in the platform. &he quickest method is to click NInsert !unctionO then select the FUser IndicatorsF category and then select the name of the indicator you want to use and click F8ddF. !or e+ample0 imagine you ha#e coded the )istogram 68'$ and named it )isto68'$. Select your indicator and click on F8ddF. Bou will see in the programming AoneC
myHi&toM +D = + LL Hi&toM +D

&he software ga#e the name Fmy)isto68'$F to the indicator F)isto68'$F. &his means that for the rest of your program0 if you want to use the )isto68'$ indicator0 you will ha#e to call it Fmy)isto68'$F.

AS &he keyword AS allows you to name the different results displayed. &his instruction is used with (ET$(N and its synta+ isC
RETURN Re&!,t1 9 J+!"3e NameJB Re&!,t2 9 J+!"3e NameJB E

&he ad#antage of this command is that it makes it easier to identify the different cur#es on your chart.

E!ample:
a = E*2onentia, 3e"age/2000(+,o&e) b = 4eighte) 3e"age/2000(+,o&e) - = 3e"age/2000(+,o&e) RETURN a 9 JE*2onentia, 3e"ageJB b 3e"ageJ

9 J4eighte)

3e"ageJB -

9 J "ithmeti-a,

COLO$(E2 COLO$(E2 is used after the (ET$(N command to color the cur#e displayed with the color of your choice0 defined with the 7DB norm 1red0 green0 blue4. &hese are the main colors of this normC Color ("B alue 3red? %reen? *lue4 1=0 =0 =4 12550 2550 2554 12550 =0 =4 1=0 2550 =4 1=0 =0 2554 12550 2550 =4 1=0 2550 2554 12550 =0 2554 En%lish Black :hite :hite Dreen Blue Bellow 'yan 6agenta

www.prorealtime.com

2 ? >.

Chapter II : Math Functions and ProBuilder instructions

&he synta+ of the 'oloured command isC


RETURN (n)i-ato" +>L>URED(Re)B K"eenB ',!e)

&he AS command can be associated with the COLO$(E21. 0 . 0 .4 command. &his association must be used in this orderC
RETURN (n)i-ato" +>L>URED(Re)B K"eenB ',!e) 9 JName >7 The +!"3eJ

5etHs go back to the pre#ious e+ample and insert COLO$(E2 in the F(ET$(NF line.
a = E*2onentia, 3e"age/2000(+,o&e) b = 4eighte) 3e"age/2000(+,o&e) - = 3e"age/2000(+,o&e) RETURN a +>L>URED(2@@B 0B 0) 9 JE*2onentia, Mo3ing 3e"ageJB b +>L>URED(0B 2@@B 0) 9 J4eighte)Mo3ing 3e"ageJB - +>L>URED(0B 0B 2@@) 9 J9im2,e Mo3ing 3e"ageJ

&his picture shows you the color customiAation of the result.

www.prorealtime.com

2" ? >.

Chapter III : Practical aspects

Chapter III : Practical aspects


-h# and ho) to create *inar# or ternar# indicators
8 binary or ternary indicator is an indicator which returns only two or three possible results 1usually =0 ( or *(4. Its main purpose in a trading conte+t is to identify #ery quickly the pattern or conditions you defined in your indicator with a #isual signal.

Purpose o+ a *inar# or ternar# indicator: $etect the main candlestick patterns 1e+C )arami0 6orning Stars0 )ammers0 M4 6ake it easier to read the chart when trying to identify specific conditions Place simple (*condition alerts on an indicator which includes se#eral conditions more alerts at your disposalG $etect comple+ conditions on historical data loaded 6ake it easier to create a backtest you will ha#e

!urthermore0 you can find in the ProBacktest manual many e+amples of stops to be inserted in in#estment strategies. Binary or ternary indicators are built essentially with I! structures. :e ad#ise you to read the I! section before continuing your reading.

5ets look at an e+ample of a binary and ternary indicatorC

Binar# Indicator: hammer detection hammer


Hamme" = +,o&e#>2en ND High = +,o&e (; Hamme" THEN Re&!,t = 1 EL9E Re&!,t = 0 END(; RETURN Re&!,t 9 JHamme"J ND (>2en-Low) #= %1(+,o&e->2en)

Ternar# Indicator: "olden Cross and 2eath Cross detection


a = E*2onentia, 3e"age/100(+,o&e) b = E*2onentia, 3e"age/200(+,o&e) - = 0 .. Ko,)en +"o&& )ete-tion (; a +R>99E9 >6ER b THEN - = 1 END(; .. Death +"o&& )ete-tion (; a +R>99E9 UNDER b THEN - = -1 END(; RETURN -

www.prorealtime.com

2% ? >.

Chapter III : Practical aspects

Note: (e ha!e displa"ed the exponential mo!ing a!erage o!er 1) and *) periods both applied to the close in order to highlight the results of the indicator# +ou can find other candlestick pattern indicators in the ,-xercises, chapter later in this manual#

Creatin% stop indicators to +ollo) a position


It is possible to create S&/P indicators0 meaning potential places to e+it the market defined by personaliAed parameters. :ith the backtesting module ProBacktest0 which is the subEect of another programming manual0 you can also define the stop le#els of a backtest. )owe#er0 programming a stop as an indicator is interesting becauseC It allows to #isualiAe the stop as a line which updates in real*time on the chart 1e+C trailing stop4 It is possible to place real*time alerts to be immediately informed of the situation It is not necessary to create long or short orders 1contrary to ProBacktest4 Programming Stops is also a means to master the commands you saw in the pre#ious chapters. &hese are the > categories of stop we will focus onC StaticTa'e Pro+it STOP Static STOP Loss Inacti,it# STOP Trailin% STOP 3trailin% stop loss or trailin% ta'e pro+it4 &he indicators presented in the following e+amples are possible codes to create stop indicators. Bou will most probably personaliAe them using the instructions you learned in the pre#ious chapters.

www.prorealtime.com

2; ? >.

Chapter III : Practical aspects

StaticTa'e Pro+it STOP 8 'tatic .ake/0rofit designates a le#el that if price reaches it0 we plan to close our position and e+it with gains. By definition0 this S&/P is a fi+ed le#el 1horiAontal line4. &he user of this kind of S&/P will e+it his position and take his profit when this le#el is reached. &he indicator coded below indicates two le#els and NStarting&imeO is the moment you entered your positionC If you are a buyer0 you will take into account the higher cur#e0 representing a (=\ profit 1((=\ of the price when you took your long position4. If you are a seller0 you will take into account the lower cur#e0 representing a(=\ profit 1;=\ of the price when you took your short position4.
.. 4e )e7ine in the 3a"iab,e o2tionG .. 9ta"tingTime = 100000 (thi& i& an e*am2,e 7o" 10 amL &et thi& to the time yo! ente"e) yo!" 2o&ition) .. 5"i-e= 5"i-e when yo! tooM yo!" 2o&ition .. No! -an ,ooM at 9to2L>NK i7 ,ooMing at a ,ong 2o&ition an) 9to29ho"t i7 yo! a"e ,ooMing at a &ho"t 2o&ition< No! -an a,&o "emo3e 9to2L>NK o" 9to29H>RT i7 yo! on,y wo"M with ,ong 2o&ition& o" on,y wo"M with &ho"t 2o&ition&< .. m2,it!)eU2 "e2"e&ent& the 3a"iation "ate o7 5"i-e !&e) to )"aw the TaMe 5"o7it 7o" ,ong 2o&ition ()e7a!,tG 1<1) .. m2,it!)eDown "e2"e&ent& the 3a"iation "ate o7 5"i-e !&e) to )"aw the TaMe 5"o7it 7o" &ho"t 2o&ition ()e7a!,tG 0<9) (; Time = 9ta"tingTime THEN 9to2L>NK = m2,it!)eU2 1 5"i-e 9to29H>RT = m2,it!)eDown 1 5"i-e END(; RETURN 9to2L>NK +>L>URED(0B 0B 0) 9 JTaMe5"o7it L>NK 10OJB 9to29H>RT +>L>URED(0B 2@@B 0) 9 JTaMe5"o7it 9H>RT 10OJ

Static STOP loss 8 'tatic '.10 5oss is the contrary of a 'tatic .ake/0rofit '.100 meaning if price reaches it0 we plan to close our position and e+it with losses. &his S&/P is #ery useful when you are losing money and try e+it the market to limit your losses to the minimum. Rust like the 'tatic .ake/0rofit0 this S&/P defines a fi+ed le#el0 but this time0 the user will e+it his position and cut his losses when this le#el is reached. &he indicator coded below indicates two le#els and NStarting&imeO is the moment you entered your positionC If you are a buyer0 you will take into account the lower cur#e0 representing a (=\ loss 1;=\ of the price when you took your long position4. If you are a seller0 you will take into account the higher cur#e0 representing a (=\ loss 1((=\ of the price when you took your short position4. &he code of this indicator isC
.. 4e )e7ine in the 3a"iab,e o2tionG .. 9ta"tingTime = 100000 (thi& i& an e*am2,e 7o" 10 amL &et thi& to the time yo! ente"e) yo!" 2o&ition) .. 5"i-e= 5"i-e when yo! tooM yo!" 2o&ition .. No! -an ,ooM at 9to2L>NK i7 ,ooMing at a ,ong 2o&ition an) 9to29ho"t i7 yo! a"e ,ooMing at a &ho"t 2o&ition< No! -an a,&o "emo3e 9to2L>NK o" 9to29H>RT i7 yo! on,y wo"M with ,ong 2o&ition& o" on,y wo"M with &ho"t 2o&ition&< .. m2,it!)eU2 "e2"e&ent& the 3a"iation "ate o7 5"i-e !&e) to )"aw the 9to2 Lo&& 7o" &ho"t 2o&ition ()e7a!,tG 0<9) .. m2,it!)eDown "e2"e&ent& the 3a"iation "ate o7 5"i-e !&e) to )"aw the T&o2 Lo&& 7o" ,ong 2o&ition ()e7a!,tG 1<1) (; Time = 9ta"tingTime THEN 9to2L>NK = m2,it!)eU2 1 5"i-e 9to29H>RT = m2,it!)eDown 1 5"i-e END(; RETURN 9to2L>NK +>L>URED(0B 0B 0) 9 J9to2Lo&& L>NK 10OJB 9to29H>RT +>L>URED(0B 2@@B 0) 9 J9to2Lo&& 9H>RT 10OJ www.prorealtime.com
.= ? >.

Chapter III : Practical aspects

Inacti,it# STOP 8n inacti#ity S&/P closes the position when the gains ha#e not obtained a certain obEecti#e 1defined in \ or in points4 o#er a certain period 1defined in number of bars4. 7emember to define the #ariables in the F-ariablesF section. 2+ample of Inacti#ity Stop on Intraday 'hartsC &his stop must be used with those two indicatorsC &he first indicator Eu+taposed to the cur#e of the price &he second indicator must be displayed in a separated chart

Indicator>
.. 4e )e7ine in the 3a"iab,e o2tionG .. My6o,ati,ity = 0<01 "e2"e&ent& 3a"iation "ate between the ea-h 2a"t o7 the "ange an) the -,o&e (; (nt"a)ay'a"(n)e* = 0 THEN 9ho"tTa"get = (1 - My6o,ati,ity) 1 +,o&e LongTa"get = (1 A My6o,ati,ity) 1 +,o&e END(; RETURN 9ho"tTa"get 9 J9ho"tTa"getJB LongTa"get 9 JLongTa"getJ

Indicator;
.. 4e )e7ine in the 3a"iab,e o2tionG REM 4e &!22o&e) that yo! taMe an J>n Ma"Met 5"i-eJ 2o&ition .. My6o,ati,ity = 0<01 "e2"e&ent& 3a"iation "ate between the ea-h 2a"t o7 the "ange an) the -,o&e .. N!mbe">7'a"&=20 G the -,o&e -an 7,!-t!ate within the "ange )e7ine) )!"ing a ma*im!m o7 N!mbe">7'a"& be7o"e the 2o&ition i& -!t (Re&!,t = 1) Re&!,t = 0 +2t = 0 (; (nt"a)ay'a"(n)e* = 0 THEN 9ho"tTa"get = (1 - My6o,ati,ity) 1 +,o&e LongTa"get = (1 A My6o,ati,ity) 1 +,o&e END(; ;>R i = (nt"a)ay'a"(n)e* D>4NT> 1 D> (; +,o&e/i0 #= 9ho"tTa"get ND +,o&e/i0 == LongTa"get THEN +2t = +2t A 1 EL9E +2t = 0 END(; (; +2t = N!mbe">7'a"& THEN Re&!,t = 1 END(; NECT RETURN Re&!,t

www.prorealtime.com

.( ? >.

Chapter III : Practical aspects

Trailin% Stop 8 trailing '.10 follows the e#olution of the price dynamically and indicates when to close a position. :e suggest you two ways to code the trailing S&/P0 the first one representing a $ynamic &railing Stop 5oss0 and the other one a $ynamic &railing &ake Profit.

2#namic Trailin% STOP LOSS 3to *e used in intrada# tradin%4


.. De7ine the 7o,,owing 3a"iab,e& in the 3a"iab,e &e-tionG .. 9ta"tingTime = 090000 (thi& i& an e*am2,e 7o" 9 amL &et thi& to the time yo! ente"e) yo!" 2o&ition) REM 4e &!22o&e) that yo! taMe an J>n Ma"Met 5"i-eJ 2o&ition .. m2,it!)e "e2"e&ent& the 3a"iation "ate o7 the J+!tJ -!"3e -om2a"e) to the JLowe&tJ -!"3e& (7o" e*am2,eB we -an taMe m2,it!)e = 0<9@) (; Time = 9ta"tingTime THEN (; ,owe&t/@0(+,o&e) = 1<2 1 Low THEN (; ,owe&t/@0(+,o&e) #= +,o&e THEN +!t = m2,it!)e 1 ,owe&t/@0(+,o&e) EL9E +!t = m2,it!)e 1 ,owe&t/200(+,o&e) END(; EL9E +!t = m2,it!)e 1 ,owe&t/200(+,o&e) END(; END(; RETURN +!t 9 JT"ai,ing 9to2 Lo&&J

2#namic Trailin% STOP Pro+it 3to *e used in intrada# tradin%4


.. De7ine the 7o,,owing 3a"iab,e& in the 3a"iab,e &e-tionG .. 9ta"tingTime = 090000 (thi& i& an e*am2,e 7o" 9 amL &et thi& to the time yo! ente"e) yo!" 2o&ition) REM No! taMe an P>n Ma"Met 5"i-eQ 2o&ition .. m2,it!)e "e2"e&ent& the 3a"iation "ate o7 the J+!tJ -!"3e -om2a"e) to the JLowe&tJ -!"3e& (7o" e*am2,eB we -an taMe m2,it!)e = 1<01@) (; Time = 9ta"tingTime THEN 9ta"ting5"i-e = +,o&e END(; 5"i-e = 9ta"ting5"i-e - 3e"ageT"!eRange/100 T"ai,ing9to2 = m2,it!)e 1 highe&t/1@0(5"i-e) RETURN T"ai,ing9to2 +>L>URED (2@@B 0B 0) 9 JT"ai,ing taMe 2"o7itJ

www.prorealtime.com

.2 ? >.

Chapter I

: E!ercises

Chapter I : E!ercises
Candlestic's patterns
"AP $P or 2O-N

&he candlesticks can be either black or white

8 gap is defined by these two conditionsC 1the current low is strictly greater than the high of the pre#ious bar4 or 1the current high is strictly lesser than the low of the pre#ious bar4 the absolute #alue of 11the current low S the high of the pre#ious bar4?the high of the pre#ious bar4 is strictly greater than amplitude4 or 11the current high S the low of the pre#ious bar4?the low of the pre#ious bar4 is strictly greater than amplitude4

.. (nitia,iRation o7 m2,it!)e m2,it!)e = 0<001 .. (nitia,iRation o7 )ete-to" Dete-to" = 0 .. Ka2 U2 .. 1&t -on)ition o7 the e*i&ten-e o7 a ga2 (; Low # High/10 THEN .. 2n) -on)ition o7 the e*i&ten-e o7 a ga2 (; '9((Low - High/10) . High/10) # m2,it!)e THEN .. 'eha3io" o7 the )ete-to" Dete-to" = 1 END(; END(; .. Ka2 Down .. 1&t -on)ition o7 the e*i&ten-e o7 a ga2 (; High = Low/10 THEN .. 2n) -on)ition o7 the e*i&ten-e o7 a ga2 (; '9((High - Low/10) . Low/10) # m2,it!)e THEN .. 'eha3io" o7 the )ete-to" Dete-to" = -1 END(; END(; .. Re&!,t )i&2,ay RETURN Dete-to" 9 JKa2 )ete-tionJ

www.prorealtime.com

.. ? >.

Chapter I

: E!ercises

2oGi 3+le!i*le ,ersion4

In this code0 we define a doEi to be a candlestick with a range 1)igh S 'lose4 is greater than 5 times the absolute #alue of 1/pen S 'lose4.

DoSi = Range # '9(>2en - +,o&e) 1 @ RETURN DoSi 9 JDoSiJ

2oGi 3strict ,ersion4

:e define the doEi with a 'lose equal to its /pen.

DoSi = (>2en = +,o&e) RETURN DoSi 9 JDoSiJ

Indicators
BO25 MOMENT$M &he Body 6omentum is mathematically defined byC Body6omentum K (== ] BodyUp ? 1BodyUp I Body$own4 BodyUp is a counter of bars for which close is greater than open during a certain number of periods. Body$own is a counter of bars for which open is greater than close during a certain number of periods.
5e"io)& = 1? b = +,o&e - >2en (; 'a"(n)e* # 5e"io)& THEN '!2 = 0 ')n = 0 ;>R i = 1 T> 5e"io)& (; b/i0 # 0 THEN '!2 = '!2 A 1 EL9(; b/i0 = 0 THEN ')n = ')n A 1 END(; NECT 'M = ('!2 . ('!2 A ')n)) 1 100 EL9E 'M = Un)e7ine) END(; RETURN 'M 9 J'o)y Moment!mJ www.prorealtime.com
.> ? >.

Chapter I

: E!ercises

ELLIOT -A E OSCILLATO( &he 2lliot wa#e oscillator shows the difference between two mo#ing a#erages. ParametersC aC short 68 periods 15 by default4 bC long 68 periods 1.5 by default4 &his oscillator permits to distinguish between wa#e . and wa#e 5 using 2lliot wa#e theory. &he short 68 shows short*term price action whereas the long 68 shows the longer term trend. :hen the prices form wa#e .0 the prices climb strongly which shows a high #alue of the 2lliot :a#e /scillator. In wa#e 50 the prices climb more slowly0 and the oscillator will show a lower #alue.
RETURN 3e"age/@0(Me)ian5"i-e) 3e"age/%@0(Me)ian5"i-e) 9 JE,,iot 4a3e >&-i,,ato"J

-illiams 6( &his is an indicator #ery similar to the Stochastic oscillator. &o draw it0 we define 2 cur#esC (4 &he cur#e of the highest of high o#er (> periods 24 &he cur#e of the lowest of low o#er (> periods &he \7 cur#e is defined by this formulaC 1'lose S 5owest 5ow 4 ? 1)ighest )igh S 5owest 5ow4 ] (==
Highe&tH = highe&t/1?0(High) Lowe&tL = ,owe&t/1?0(Low) My4i,,iam& = (+,o&e - Lowe&tL) . (Highe&tH - Lowe&tL) 1 100 RETURN My4i,,iam& 9 J4i,,iam& ORJ

Bollin%er Bands &he middle band is a simple 2=*period mo#ing a#erage applied to close. &he upper band is the middle band plus 2 times the standard de#iation o#er 2= periods applied to close. &he lower band is the middle band minus 2 times the standard de#iation o#er 2= periods applied to close.
a = 3e"age/200(+,o&e) .. 4e )e7ine the &tan)a") )e3iation< 9t)De3iation = 9TD/200(+,o&e) '&!2 = a A 2 1 9t)De3iation 'in7 = a - 2 1 9t)De3iation RETURN a 9 J 3e"ageJB '&!2 9 J'o,,inge" U2JB 'in7

9 J'o,,inge" DownJ

www.prorealtime.com

.5 ? >.

"lossar#

"lossar# A
Code
'9 --!mDi&t" DC DCR ND "oonDown "oonU2 T N 9 3e"age 3e"ageT"!eRange

S#nta! 8BS1a4 8ccum$istr1close4 8$9P3Q 8$97P3Q a 83$ b 8roon$ownP3Q 8roonUpP3Q 8&831a4 72&U73 7esult 8S F7esult3ameF 8#erageP3Q1price4 8#erage&rue7angeP3Q1price4

Function 6athematical function F8bsolute -alueF of a 'lassical 8ccumulation?$istribution indicator Indicator 8#erage $irectional Inde+ or F8$9F of n periods Indicator 8#erage $irectional Inde+ 7ate or F8$97F of n periods 5ogical 83$ /perator 8roon $own indicator of n periods 8roon Up indicator of n periods 6athematical function F8rctangentF of a Instruction used to name a line or indicator displayed on chart. Used with F72&U73F Simple 6o#ing 8#erage of n periods F8#erage &rue 7angeF * &rue 7ange smoothed with the :ilder method

B
Code
'a"(n)e*

S#nta! BarInde+

Function 3umber of bars since the beginning of data loaded 1in a chart in the case of a ProBuilder indicator or for a trading system in the case of ProBacktestProBacktest or ProIn#est4 Bollinger Bandwidth indicator 5ower Bollinger band Upper Bollinger band

'o,,inge"'an)4i)th 'o,,inge"Down 'o,,inge"U2 'RE F

BollingerBand:idthP3Q1price4 Bollinger$ownP3Q1price4 BollingerUpP3Q1price4

1!/7...$/...B728<...329&4 Instruction forcing the e+it of !/7 loop or or :)I52 loop 1:)I52...$/...B728<...:23$4

www.prorealtime.com

. ? >.

"lossar#

C
Code
+ LL ++( +haiMin>&+han),e +han)eF"o,,9to2U2 +han)eF"o,,9to2Down +,o&e +>L>URED +>9 +R>99E9 >6ER +R>99E9 UNDER -!m&!m +!""entDay>74eeM +!""entHo!" +!""entMin!te +!""entMonth +!""ent9e-on) +!""entTime +!""entNea" +!&tom+,o&e +y-,e

S#nta!

Function

my7esult K '855 my!unction 'alls a user indicator to be used in the program you are coding ''IP3Q1price4 or ''IP3Q 'haikin/scP'h(0 'h2Q1price4 'handleP3Q1price4 'hande<rollStopUpPPp0 ^q0 9Q 'hande<rollStop$ownPPp0 ^q0 9Q 'loseP3Q 72&U73 7esult '/5/U72$170D0B4 '/S1a4 a '7/SS2S /-27 b a '7/SS2S U3$27 b cumsum1price4 'urrent$ay/f:eek 'urrent)our 'urrent6inute 'urrent6onth 'urrentSecond 'urrent&ime 'urrentBear 'ustom'loseP3Q 'ycle1price4 'ommodity 'hannel Inde+ indicator 'haikin oscillator 'hande 6omentum /scillator 'hande and <roll Protection Stop on long positions 'hande and <roll Protection Stop on short positions 'losing price of the current bar or of the n*th last bar 'olors a cur#e with the color you defined using the 7DB con#ention 'osine !unction Boolean /perator checking whether a cur#e has crossed o#er another one Boolean /perator checking whether a cur#e has crossed under another one Sums a certain price on the whole data loaded 7epresents the current day of the week 7epresents the current hour 7epresents the current minute 7epresents the current month 7epresents the current second 7epresents the current time 1))66SS4 7epresents the current year 'onstant which is customiAable in the settings window of the chart 1defaultC 'lose4 'ycle Indicator

www.prorealtime.com

." ? >.

"lossar#

2
Code
Date Day Day& Day>74eeM D+,o&e DEM DHigh D( D(min!& D(2,!& DLow D> D>2en D>4NT> D5>

S#nta! $ateP3Q $ayP3Q $aysP3Q $ay/f:eekP3Q $'lose134 $268P3Q1price4 $)igh134 $IP3Q1price4 $IminusP3Q1price4 $IplusP3Q1price4 $5ow134 See !/7 and :)I52 $/pen134 See !/7 $P/P3Q1price4

Function 7eports the date of each bar loaded on the chart 7eports the day of each bar loaded in the chart 'ounter of days since (;== $ay of the week of each bar 'lose of the n*th day before the current one $ouble 2+ponential 6o#ing 8#erage )igh of the n*th bar before the current bar 7epresents $II minus $I* 7epresents the $I* indicator 7epresents the $II indicator 5ow of the n*th day before the current one /ptional instruction in !/7 loop and :)I52 loop to define the loop action /pen of the n*th day before the current one Instruction used in !/7 loop to process the loop with a descending order $etrented Price /scillator

E
Code
Ea&e>7Mo3ement EL9E EL9E(; EM6 END(; En)5oint 3e"age EC5 E*2onentia, 3e"age

S#nta! 2ase/f6o#ementPIQ See I!?&)23?25S2?23$I! See I!?&)23?25SI!?25S2?23$I! 26-P3Q See I!?&)23?25S2?23$I! 2ndPoint8#erageP3Q1price4 29P1a4 2+ponential8#erageP3Q1price4

Function 2ase of 6o#ement indicator Instruction used to call the second condition of If*conditional statements Stands for 2lse If 1to be used inside of conditional loop4 2ase of 6o#ement -alue indicator 2nding Instruction of I!*conditional statement 2nd Point 6o#ing 8#erage of a 6athematical !unction F2+ponentialF 2+ponential 6o#ing 8#erage

www.prorealtime.com

.% ? >.

"lossar#

F7"
Code
;>R.T>.NECT

S#nta! !/7 iKa &/ b $/ a 329&

Function !/7 loop 1processes all the #alues with an ascending 1&/4 or a descending order 1$/:3&/44 !orce Inde+ indicator 1determines who controls the market 1buyer or seller4

;o"-e(n)e*

!orceInde+1price4

1
Code
High highe&t Hi&to"i-6o,ati,ity Ho!"

S#nta! )ighP3Q highestP3Q1price4 )istoric-olatilityP3Q1price4 )ourP3Q

Function )igh of the current bar or of the n*th last bar )ighest price o#er a number of bars to be defined )istoric -olatility 1or statistic #olatility4 7epresents the hour of each bar loaded in the chart

I7H7@
Code
(;.THEN.END(; (;.THEN.EL9E.END(; (nt"a)ay'a"(n)e*

S#nta! I! a &)23 b 23$I! I! a &)23 b 25S2 c 23$I! IntradayBarInde+P3Q

Function Droup of conditional instructions without second instruction Droup of conditional instructions 'ounts how many bars are displayed in one day on the whole data loaded

L
Code
Linea"Reg"e&&ion

S#nta! 5inear7egressionP3Q1price4 1price4

Function 5inear 7egression inidcator Slope of the 5inear 7egression inidcator 6athematical !unction F3eperian logarithmF of a 5ow of the current bar or of the n*th last bar 5owest price o#er a number of bars to be defined

Linea"Reg"e&&ion9,o2e 5inear7egressionSlopeP3Q L>K Low ,owe&t

5/D1a4 5owP3Q lowestP3Q1price4

www.prorealtime.com

.; ? >.

"lossar#

M
Code
M +D M +D,ine Ma&&(n)e* M C Me)ian5"i-e M(N Min!te M>D Moment!m Money;,ow Money;,ow(n)e* Month

S#nta! 68'$PS050SiQ1price4 68'$5inePS05Q1price4 6assInde+P3Q 6891a0b4 6edianPrice 6I31a0b4 6inute a 6/$ b 6omentumPIQ 6oney!lowP3Q1price4 6oney!lowInde+P3Q 6onthP3Q

Function 6o#ing 8#erage 'on#ergence $i#ergence 168'$4 in histogram 68'$ line indicator 6ass Inde+ Indicator applied o#er 3 bars 6athematical !unction F6a+imumF 8#erage of the high and the low 6athematical !unction F6inimumF 7epresents the minute of each bar loaded in the chart 6athematical !unction Fremainder of the di#isionF 6omentum indicator 1close S close of the n*th last bar4 6oney!low indicator 1result between *( and (4 6oney!low Inde+ indicator 7epresents the month of each bar loaded in the chart

N
Code
NECT N>T

S#nta! See !/7?&/?329& 3ot 8

Function 2nding Instruction of !/7 loop 5ogical /perator 3/&

O
Code
>'6 >N+E >2en >R

S#nta! /B-1price4 /3'2 -ariable3ame K -ariable-alue /penP3Q a /7 b

Function /n*Balance*-olume indicator Introduces a definition statement which will be processed only once /pen of the current bar or of the n*th last bar 5ogical /perator /7

P7C
Code
5"i-e>&-i,,ato" 5o&iti3e6o,!me(n)e* 56T

S#nta! Price/scillatorPS05Q1price4 Price-olumeInde+1price4 P-&1price4

Function Percentage Price oscillator Positi#e -olume Inde+ indicator Price -olume &rend indicator

www.prorealtime.com

>= ? >.

"lossar#

(
Code
R2 Range REM Re2!,&e RETURN R>+ R9( R>UND

S#nta! 72P3Q1price4 7angeP3Q 726 comment 7epulseP3Q1price4 72&U73 7esult 7/'P3Q1price4 7SIP3Q1price4 7/U3$1a4

Function 7*Squared indicator 1error rate of the linear regression on price4 calculates the 7ange 1)igh minus 5ow4 Introduces a remark 1not taken into account by the code4 7epulse indicator 1measure the buyers and sellers force for each candlestick4 Instruction returning the result Price 7ate of 'hange indicator 7elati#e Strength Inde+ indicator 6athematical !unction F7ound a to the nearest whole numberF

S
Code
9 R 9 Rat)m7 9(N 9KN 9M( 9moothe)9to-ha&ti9IU RE 9IRT 9TD 9TE 9to-ha&ti&!mmation 9!2e"t"en)

S#nta! S87P8t0St05imQ S87atdmfP8t0St05imQ1price4 SI31a4 SD31a4 S6IP30SS0$SQ1price4 SmoothedStochasticP30<Q 1price4 S^U8721a4 S^7&1a4 S&$P3Q1price4 S&2P3Q1price4 StochasticP30<Q1price4 summationP3Q1price4 SupertrendPS&!03Q

Function Parabolic S87 indicator Smoothed Parabolic S87 indicator 6athematical !unction FSineF 6athematical !unction FSign ofF a 1it is positi#e or negati#e4 Stochastic 6omentum Inde+ indicator Smoothed Stochastic 6athematical !unction Fa SquaredF 6athematical !unction FSquared 7ootF of a Statistical !unction FStandard $e#iationF Statistical !unction FStandard 2rrorF \< 5ine of the Stochastic indicator Sums a certain price o#er the 3 last candlesticks Super &rend indicator

www.prorealtime.com

>( ? >.

"lossar#

T
Code
T N TEM THEN Time Time9e"ie& 3e"age T> To)ay Tota,5"i-e TR T"iang!,a" 3e"age TR(C Ty2i-a,5"i-e

S#nta! &831a4 &268P3Q1price4 See I!?&)23?25S2?23$I! &imeP3Q &imeSeries8#erageP3Q1price4 See !/7?&/?329& &odayP3Q &otalPriceP3Q &71price4 &riangular8#erageP3Q1price4 &7I9P3Q1price4 &ypicalPriceP3Q

Function 6athematical !unction F&angentF of a &riple 2+ponential 6o#ing 8#erage Instruction following the first condition of FI!F 7epresents the time of each bar loaded in the chart &emporal series mo#ing a#erage $irectional Instruction in the F!/7F loop $ate of the bar n*periods before the current bar 1'lose I /pen I )igh I 5ow4 ? > &rue 7ange indicator &riangular 6o#ing 8#erage &riple Smoothed 2+ponential 6o#ing 8#erage 7epresents the &ypical Price 18#erage of the )igh0 5ow and 'lose4

$
Code
Un)e7ine)

S#nta! a K Undefined

Function Sets a the #alue of a #ariable to undefined

Code
6a"iation 6o,ati,ity 6o,!me 6o,!me>&-i,,ato" 6o,!meR>+

S#nta! -ariation1price4 -olatilityPS0 5Q -olumeP3Q -olume/scillatorPS05Q -olume7/'P3Q

Function $ifference between the close of the last bar and the close of the current bar in \ 'haikin #olatility -olume indicator -olume /scillator -olume of the Price 7ate /f 'hange

www.prorealtime.com

>2 ? >.

"lossar#

Code
4eighte) 3e"age 4eighte)+,o&e 4END 4H(LE.D>.4END 4i,)e" 3e"age 4i,,iam& 4i,,iam& --!mDi&t"

S#nta! :eighted8#erageP3Q1price4 :eighted'loseP3Q See :)I52?$/?:23$

Function 7epresents the :eighted 6o#ing 8#erage 8#erage of 12 ] 'lose40 1( ] )igh4 and 1( ] 5ow4 2nding Instruction of :)I52 loop

:)I52 1condition4 $/ 1action4 :)I52 loop :23$ :ilder8#erageP3Q1price4 :illiamsP3Q1close4 :illiams8ccum$istr1price4 7epresents :ilder 6o#ing 8#erage \7 de :illiams indicator 8ccumulation?$istribution of :illiams Indicator

0
Code
C>R

S#nta! a 9/7 b

Function 5ogical /perator e9clusi#e /7

5
Code
Nea" Ne&te")ay

S#nta! BearP3Q BesterdayP3Q

Function Bear of the bar n periods before the current bar $ate of the day preceeding the bar n periods before the current bar

I
Code
TigTag TigTag5oint

S#nta! JigJagPJrQ1price4 JigJagPointPJpQ1price4

Function 7epresents the Jig*Jag indicator introduced in the 2liott wa#es theory 7epresents the Jig*Jag indicator in the 2liott wa#es theory calculated on Jp points

Other
Code
A 1 . = =#

Function 8ddition /perator Substraction /perator 6ultiplication /perator $i#ision /perator 2quality /perator $ifference /perator

Code
= # == #= ..

Function Strict Inferiority /perator Strict Superiority /perator Inferiority /perator Superiority /perator Introduces a commentary line

www.prorealtime.com

>. ? >.

www.prorealtime.com

You might also like