• No se han encontrado resultados

Dosimetr´ıa cl´ınica

3.1 Maniqu´ıes num´ ericos

profile <variable_name>=<expression>; or profile <variable_name>; <variable_name>=<expression>; Description

Defines a profile to be displayed on the chart.

orec

Syntax rec

Description

Enables you to reference a historical value of a variable that you are calculating in the study or strategy itself. Rec is short for "recursion".

See the Defining Variables section for more details. Example

rec C = C[1] + volume; plot CumulativeVolume = C;

This example plots the cumulative volume starting from the beginning of the time period.

oreference

Syntax

reference <StudyName>(parameter1=value1,.., parameterN=valueN).<PlotName>

Description

References a plot from another script. Note that the reference reserved word can be dropped but in this case parenthesis are necessary.

Full form:

plot MyMACD = reference MACDHistogram; Compressed form:

plot MyMACD = MACDHistogram();

The reference reserved work is required to distinguish the VWAP study from the vwap function, MoneyFlow study from the moneyflow function.

Calling the vwap function: plot MyVWAP1 = vwap; Referenicing the VWAP study: plot MyVWAP1 = reference VWAP;

If the plot name is not defined, study's main plot should be referenced (main is the first declared in the source code). If parameters values are not defined, default values should be used. Inputs' names can be dropped only for ThinkScript studies, because they have fixed order of inputs in the code: Full form:

plot MyBB2 = BollingerBandsSMA(price = open, displace = 0, length = 30);

Compact form:

Example

The following example references def and rec instead of the plot as shown at the top of the article.

def st = ATRTrailingStop().state; AssignPriceColor(if st == 1 then GetColor(1) else if st == 2 then GetColor(0) else Color.CURRENT);

def bs = !IsNaN(close) and ATRTrailingStop().BuySignal == yes;

def ss = !IsNaN(close) and ATRTrailingStop().SellSignal == yes; AddVerticalLine(bs or ss, if bs then "Buy!" else "Sell!", if bs then GetColor(0) else GetColor(1));

st is the reference to the state enum rec from the ATRTrailingStop study, bs and ss are references to the BuySignal and SellSignal def from the same study.

oscript

Syntax

script <script_name> { <script_code>; } Description

This reserved word is used to define new scripts you may need to reference later within a certain study or strategy.

Example script MyEMA { input data = close; input length = 12;

rec EMA = compoundValue(1, 2 / (length + 1) * data + (length - 1) / (length + 1) * EMA[1], Average(data, length)); plot MyEma = EMA;

}

declare lower;

plot Osc = MyEMA(close, 25) - MyEMA(close, 50);

This code defines the MyEma script where the first EMA value is calculated as SMA in contrast to the ExpAverage function whose first value is assigned the closing price. The main section of the code creates an oscillator based on the MyEMA difference for different lenghts.

oswitch

Syntax

plot <plot_name>;

switch (<enum input or enum_rec>) { case <enum value1>:

<plot_name> = <expression1>; ... default: <plot_name> = <expression>; } Description

The switch statement is used to control the flow of program execution via a multiway branch using the enum rec, and enum input. In the switch statement you either need to define the case with all values from the enum. Or you can use the default statement to define actions for all enums that are not defined using the case. Note that in this approach you cannot use case with equal enums.

Example

input price = close;

input plot_type = {default SMA, "Red EMA", "Green EMA", WMA}; plot Avg; switch (plot_type) { case SMA: Avg = Average(price); case WMA: Avg = wma(price); default: Avg = ExpAverage(price); } Avg.SetDefaultColor(

if plot_type == plot_type."Red EMA" then color.RED else if plot_type == plot_type."Green EMA" then color.GREEN else color.BLUE);

This example illustrates the usage of the switch reserved word to assign different values to plots. The default keyword must be used unless all possible values of variable are explicitly listed.

othen

Syntax

See the if reserved word article. Description

The reserved word is used to specify an action to be performed when the if condition is satisfied. This reserved word is used only in combination with the if statement.

oto

Syntax

def <result> = fold <index> = <start> to <end> with <variable> [ = <init> ] [ while <condition> ] do <expression>;

Description

The reserved word is used to define an interval to be used when calculating the fold function. For more information, see the fold reserved word article.

owhile

Syntax

def <result> = fold <index> = <start> to <end> with <variable> [ = <init> ] [ while <condition> ] do <expression>;

Description

This reserved word defines a condition upon violation of which the loop is terminated when calculating the fold function. For more information, see the fold reserved word article.

owith

Syntax

def <result> = fold <index> = <start> to <end> with <variable> [ = <init> ] [ while <condition> ] do <expression>;

Description

The reserved word is used to define an iteration step value in the fold function. For more information, see the fold reserved word article.

oyes

Syntax yes

Description

The yes reserved word is used as a value for the boolean input or as the true condition. In order to define the true condition, you can also use 1 or any non-zero number.

Example

input DisplayPlot = yes; plot Data = close;

Data.SetHiding(!DisplayPlot);

In this study, DisplayPlot input controls visibility of plot. Its default value is yes.

o

Declarations

Declarations are responsible for basic operations performed with charts such as changing the recalculation mode or setting the minimal chart value to zero. An important difference of declarations from other thinkscript items is that in order to define a declaration you need to use the declare reserved word.

The section contains the following declarations: • all_for_one • hide_on_daily • hide_on_intradayloweron_volumeonce_per_bar • real_size • upperweak_volume_dependencyzerobase