Você está na página 1de 12

INDEX

FML Referencing Existing Custom Indicators Creating Custom Indicators with Multiple Plots SYNTAX - Formula Variable Call 2 2 4 6 FML

INDICE
2 Referenciando Indicadores de Customizados (Feitos Sob Encomenda) Existentes 2 Criando indicadores Feitos sob Encomenda com Mltiplos Grficos 4 SINTAXE - Formula Call (Frmula de Chamada) Usando Variveis Matemticas para Representar 6

Using Variables to Represent Mathematical Expressions 7

Expresses 7

FMLVAR Referencing Variables within Custom Indicators SYNTAX - Formula Variable Call

10 10 12

FMLVAR Referenciando Existentes Indicadores Feitos sob

10 Encomenda 10

SINTAXE - Formula Variable Call (Frmula de Chamada de Varivel) 12

22/08/2008

1/12

FML
Referencing Existing Custom Indicators You can reference other custom indicators using the fml() function. For example, the function "fml( "My MACD")" is the value of the formula that contains the text "My MACD" in its name. The entire name is not required--only enough of the name to make it unique. However, preference is given to the formula name that exactly matches. So if another formula named "MyMACD2" existed, "MyMACD" would be used since it matches exactly. The following formula plots the value of the formula named "Down Day" if the close is less-than-or-equal-to a 10-period exponential moving average of the closing prices. Otherwise, it plots the value of the formula named "Up Day." if( close <= mov(close, 10, E), fml("Down Day"), fml("Up Day") ) This technique (referencing formulas from within formulas) is referred to as the "nesting of formulas." Using nested formulas is an excellent way to simplify long and/or complex formulas. Referenciando Indicadores de Customizados (Feitos Sob Encomenda) Existentes Voc pode referenciar outros indicadores feitos sob encomenda usando a funo fml(). Por exemplo, a funo "fml ("Meu MACD")" o valor da frmula que contm o texto "Meu MACD" em seu nome. O nome inteiro no exigido, somente o suficiente do nome para faz-lo nico. Porm, a preferncia dada ao nome de frmula que combina exatamente. Assim se outra frmula chamada de "MyMACD2" existiu, "MyMACD" seria usado desde que combinasse exatamente. A frmula seguinte desenha o valor da frmula chamada "Down Day" se o fechamento estiver menor ou igual a uma mdia mvel exponencial de 10 perodos dos preos de fechamento. Caso contrrio desenha o valor da frmula chamada de "Up Day". if( close <= mov(close, 10, E), fml("Down Day"), fml("Up Day") ) Esta tcnica (referenciando frmulas dentro de frmulas) chamada como "nesting of formulas" (embutimento de frmulas). Usando o embutimento de frmulas uma maneira excelente para simplificar frmulas longas e/ou complexas.

FML
22/08/2008 2/12

Also note, that nested formulas may reference nested formulas that reference nested formulas (etc.). However, circular references (e.g., formula "My MACD" calls formula "My RSI" that calls formula "My MACD") will cause an error message to be displayed when the formula is plotted.

referenciar as frmulas embutidas que referencia as frmulas embutidas (etc.). Porm, referncias circulares (por exemplo, a frmula "Meu MACD" chama a frmula "Meu RSI" que chama a frmula "Meu MACD") causaro uma mensagem de erro ao ser exibida quando a frmula for desenhada. Se uma frmula de multi-parcelas for referenciada, s o valor da ltima parcela da frmula de multi-parcelas ser retornado. Se voc precisa referenciar o valor de uma varivel especfica em um indicador feito sob encomenda em lugar do valor do prprio indicador feito sob encomenda, use a funo do fmlvar() (veja Referencing Variables within Custom Indicators - Referenciando Variveis dentro de Indicadores Feitos sob Encomenda).

If a multiplot formula is referenced, only the value of last plot in the multiplot formula is returned. If you need to reference the value of a specific variable in a custom indicator rather than the value of the custom indicator itself, use the fmlvar() function (see Referencing Variables within Custom Indicators).

Creating Custom Indicators with Multiple Plots Note tambm que o embutimento de frmulas pode 22/08/2008 3/12

Many indicators require two or more plots for their correct interpretation. One such indicator is the MACD. The MACD uses a moving average (called the signal line) to generate crossover signals. Every unassigned expression (i.e., those expressions not assigned to a variable) in a custom indicator will result in a separate plot on the chart. For example, the following formula entered as a custom indicator will result in two plots: DiffOfAvg:= mov(c,39,s)-mov(c,200,s); DiffOfAvg; mov(DiffOfAvg, 9,s); The first statement assigns the expression "mov(c,39,s)mov(c,200,s)" to a variable named "DiffOfAvg". The second statement results in a plot of DiffOfAvg. The third statement results in a plot of a 9-period moving average of DiffOfAvg. Notice that each expression must end with a semi-colon. If you use the fml() function (see Referencing Existing Custom Indicators) to call a custom indicator containing multiple plots, only the last plot in the custom indicator will be returned by the fml() function.

sua interpretao correta. Um indicador semelhante o MACD. O MACD usa uma mdia mvel (chamada de linha de sinal) gerar sinais de cruzamento. Toda expresso sem sinal (isto , aquelas expresses no atribudas a uma varivel) em um indicador feito sob encomenda resultar em um desenho separado no grfico. Por exemplo, a seguinte frmula incorporada como um indicador feito sob encomenda resultar em dois grficos: DiffOfAvg:= mov(c,39,s)-mov(c,200,s); DiffOfAvg; mov (DiffOfAvg, 9,s); A primeira declarao atribui a expresso "mov (c,39,s)mov (c,200,s)" para uma varivel nomeado "DiffOfAvg". A segunda declarao resulta em um desenho de DiffOfAvg. A terceira declarao resulta em um desenho de uma mdia mvel de 9 perodos de DiffOfAvg. Observe que a cada expresso deve terminar com um ponto e vrgula. Se voc usar a funo fml () (veja Referencing Existing Custom Indicators - Referenciando Indicadores de Feito sob Encomenda Existentes) para chamar um indicador feito sob encomenda contendo mltiplos grficos, somente o ltimo desenho no indicador feito sob encomenda ser retornado pela funo fml (). For example, if a formula using the fml() function called the following custom indicator, only the 10-period moving average would be returned, since it is the last plot.

Criando indicadores Feitos sob Encomenda com Mltiplos Grficos Muitos indicadores requerem dois ou mais grficos para a 22/08/2008

4/12

mov(close,30,s); mov(close,20,s); mov(close,10,s); To change the color of the individual plots of a multiple plot indicator, plot the indicator, then change the properties of each plot.

mov(close,30,s); mov(close,20,s); mov (close,10,s); Para mudar a cor dos grficos individuais de um indicador de desenho mltiplos, desenhe o indicador, ento mude as propriedades de cada desenho.

SYNTAX - Formula Call Por exemplo, se uma frmula que usa a funo fml () chama o indicador feito sob encomenda seguinte, somente a mdia mvel de 10 perodo seria devolvida, desde que o ltimo desenho. SYNTAX fml("FORMULA_NAME" )

FUNCTION Calculates the value of another formula. The 22/08/2008 5/12

formula can be referenced FORMULA_NAME in quotes.

using

the

FORMULA_NAME entre aspa. Quando referenciando o nome da frmula, o nome deve estar contidos entre aspa (por exemplo, fml ("Secret A")). Se voc mudar um nome da frmula, voc deve tambm mudar qualquer chamada fml() que referncia aquela frmula. EXEMPLO A formula "fml("Secret A") * fml("MyMACD")" calcula o valor da formula chamada "Secret A" multiplicada pela formula "MyMACD."

When referencing a formula's name, the name must be contained in quotation marks (e.g., fml( "Secret A")). If you change a formula's name, you must also change any fml() calls that reference that formula. EXAMPLE The formula "fml("Secret A") * fml("MyMACD")" calculates the value of the formula named "Secret A" multiplied by "MyMACD." See Referencing Existing Custom Indicators for more details on using the fml() function.

SEE ALSO

TAMBM VEJA Veja Referencing Existing Custom Indicators para mais detalhes sobre o uso da funo fmlvar().

Using Variables to Represent Mathematical Expressions SINTAXE - Formula Call (Frmula de Chamada) SINTAXE FUNO fml("FORMULA_NAME" ) NOME_DE_FORMULA") Chama o valor de outra formula. A formula pode ser referenciada usando a 6/12 Variables can be assigned to represent a mathematical expression (i.e., formula). Perhaps this is the most useful benefit of variables. Assigning variables to represent formulas (especially long, complex ones) makes formulas easier to read, easier to modify, and faster to calculate.

22/08/2008

For example, the following formula (designed to spot securities locked between support and resistance levels), is quite complex and difficult to read. It can be simplified by using variables. It was originally written before variable support was added to MetaStock's formula language.

ativos travados entre os nveis de suporte e resistncia), so bastante complexas e difceis de ler. Pode ser simplificadas usando variveis. Originalmente foi escrito antes do suporte a varivel fosse acrescentado frmula de linguagem do MetaStock.

Usando Variveis para Representar Expresses Matemticas As variveis podem ser nomeadas para representar uma expresso matemtica (isto , frmula). Talvez esta seja o benefcio mais til das variveis. Variveis nomeadas para representar frmulas (especialmente longas, complexas) fazem frmulas mais fceis para ler, mais fcil para modificar, e mais rapidamente para calcular. Por exemplo, a seguinte frmula (projetada para marcar 22/08/2008

(If(Abs((Trough(1,L,1)-Trough(2,L,1))/Trough(2,L,1))<.015 AND Abs((Trough(2,L,1)Trough(3,L,1))/Trough(3,L,1))<.015,{then} (Trough(1,L,1)+Trough(2,L,1)+Trough(3,L,1))/3,0))<>0 and (If(Abs((Peak(1,H,1)-Peak(2,H,1))/Peak(2,H,1))<.015 AND Abs((Peak(2,H,1)-Peak(3,H,1))/Peak(3,H,1))<.015,{then} (Peak(1,H,1)+Peak(2,H,1)+Peak(3,H,1))/3,0))<>0

7/12

and c>=(If(Abs((Trough(1,L,1)Trough(2,L,1))/Trough(2,L,1))<.015 AND Abs((Trough(2,L,1)-trough(3,L,1))/Trough(3,L,1))<.015, {then} (Trough(1,L,1)+Trough(2,L,1)+Trough(3,L,1))/3,0)) and c<=(If(Abs((Peak(1,H,1)-Peak(2,H,1))/Peak(2,H,1))<.015 AND Abs((Peak(2,H,1)-Peak(3,H,1))/Peak(3,H,1))<.015, {then} (Peak(1,H,1)+Peak(2,H,1)+Peak(3,H,1))/3,0) By defining two variables (in bold) to represent the two expressions that are used repeatedly, you can simplify the formula substantially. In addition to being easier to read, the simplified formula also calculates quicker since the support and resistance expressions now only need to calculate once. (If(Abs((Trough(1,L,1)-Trough(2,L,1))/Trough(2,L,1))<.015 AND Abs((Trough(2,L,1)Trough(3,L,1))/Trough(3,L,1))<.015,{then} (Trough(1,L,1)+Trough(2,L,1)+Trough(3,L,1))/3,0))<>0 and (If(Abs((Peak(1,H,1)-Peak(2,H,1))/Peak(2,H,1))<.015 AND Abs((Peak(2,H,1)-Peak(3,H,1))/Peak(3,H,1))<.015,{then} (Peak(1,H,1)+Peak(2,H,1)+Peak(3,H,1))/3,0))<>0 and 22/08/2008 8/12 Resistance:= (If(Abs((Peak(1,H,1)Peak(2,H,1))/Peak(2,H,1))<.015 AND Abs((Peak(2,H,1)-Peak(3,H,1))/Peak(3,H,1))<.015, {then}(Peak(1,H,1)+Peak(2,H,1)+Peak(3,H,1))/3,0)); c>=(If(Abs((Trough(1,L,1)Trough(2,L,1))/Trough(2,L,1))<.015 AND Abs((Trough(2,L,1)-trough(3,L,1))/Trough(3,L,1))<.015, {then} (Trough(1,L,1)+Trough(2,L,1)+Trough(3,L,1))/3,0)) and c<=(If(Abs((Peak(1,H,1)-Peak(2,H,1))/Peak(2,H,1))<.015 AND Abs((Peak(2,H,1)-Peak(3,H,1))/Peak(3,H,1))<.015, {then} (Peak(1,H,1)+Peak(2,H,1)+Peak(3,H,1))/3,0) Definindo duas variveis (em tipo negrito) para representar as duas expresses que so repetidamente usadas, voc pode simplificar a frmula substancialmente. Alm de ser mais fcil de ler, a frmula simplificada calcula tambm mais rapidamente agora que as expresses de suporte e de resistncia agora necessitam somente calcular uma vez.

Support:= (If(Abs((Trough(1,L,1)trough(2,L,1))/Trough(2,L,1))<.015 AND Abs((Trough(2,L,1)trough(3,L,1))/Trough(3,L,1))<.015,{then} (Trough(1,L,1)+Trough(2,L,1)+Trough(3,L,1))/3,0));

Support <> 0 and Resistance <> 0 and close >= Support and close <= Resistance Note that you could also create individual custom indicators named "support" and "resistance" to do the calculations. (See Referencing Existing Custom Indicators for more information on using the fml() function.) These custom indicators could then be called using the fml() function as follows:

Support and close <= Resistance Note que voc tambm poderia criar indicadores feitos sob encomenda individuais nomeados de "suporte" e "resistncia" para fazer os clculos. (Veja Referencing Existing Custom Indicators - Referenciando Indicadores Feitos sob Encomenda Existentes para mais informao em usar a funo do fml()). Estes indicadores feitos sob encomenda poderiam ento ser chamados usando a funo do fml() como segue:

Support:= (If(Abs((Trough(1,L,1)trough(2,L,1))/Trough(2,L,1))<.015 AND Abs((Trough(2,L,1)trough(3,L,1))/Trough(3,L,1))<.015,{then} (Trough(1,L,1)+Trough(2,L,1)+Trough(3,L,1))/3,0)); Resistance:= (If(Abs((Peak(1,H,1)Peak(2,H,1))/Peak(2,H,1))<.015 AND Abs((Peak(2,H,1)-Peak(3,H,1))/Peak(3,H,1))<.015, {then}(Peak(1,H,1)+Peak(2,H,1)+Peak(3,H,1))/3,0)); Support <> 0 and Resistance <> 0 and close >= 22/08/2008

fml("support") <> 0 and fml("resistance") <> 0 and close >= fml("support") and close <= fml("resistance") However, using variables is generally more desirable than using the fml() function for several reasons the most important being calculation speed and self-containment (i.e., the entire function can be read and edited in one place).

9/12

fml("support") <> 0 and fml("resistance") <> 0 and close >= fml("support") and close <= fml("resistance") Porm, usar variveis geralmente mais desejvel do que usar a funo do fml() por diversas razes a mais importante existente a velocidade de clculo e autoreteno (isto , a funo inteira pode ser lida e pode ser editada em um lugar).

22/08/2008

10/12

FMLVAR
Referenciando Indicadores Feitos sob Encomenda Existentes Referencing Variables within Custom Indicators Since custom indicators can contain variables, you can reference a specific variable within a custom indicator rather than the entire custom indicator. The fmlvar() function is used to do this. For example, if the custom indicator named "MyMACD" contains a variable named "SignalLine," and you only want to reference the SignalLine variable, it could be done as follows using the fmlvar() function: fmlvar("MyMACD", "SignalLine" ) If the variable does not exist within the custom indicator, you will receive an error message. Considerando que indicadores feitos sob encomenda podem conter variveis, voc pode referenciar uma varivel especfica dentro de um indicadores feitos sob encomenda em lugar do indicadores feitos sob encomenda inteiro. A funo fmlvar() usada para fazer isto. Por exemplo, se o indicador feito sob encomenda nomeado "MyMACD" contiver uma varivel nomeada "SignalLine", e voc s quer a referenciar a varivel SignalLine, poderia ser feito como segue usando a funo fmlvar(): fmlvar ("MyMACD", "SignalLine"). Se a varivel no existir dentro do indicador feito sob encomenda, voc receber uma mensagem de erro.

FMLVAR 22/08/2008

SYNTAX - Formula Variable Call 11/12

SINTAXE SYNTAX fmlvar( "FORMULA_NAME", "VARIABLE_NAME") FUNO FUNCTION Calls the custom indicator named FORMULA_NAME and returns the value contained in the custom indicator's variable named VARIABLE_NAME.

fmlvar( "FORMULA_NAME", "VARIABLE_NAME" NOME_DE_FORMULA", "NOME_DE_VARIABLE") Chama o indicador feito sob encomenda nomeado FORMULA_NAME e retorna com o valor contido na varivel do indicador feito sob encomenda nomeada VARIABLE_NAME.

Both the formula's name and the variable's name must be contained in quotation marks (e.g., fmlvar ("Secret A", "MyVar")). If you change a formula or variable name, you must also change any fmvarl() calls that reference that formula and variable. EXAMPLE SEE ALSO fmlvar("MyIndicator", "MyVariableA" ) See Referencing Variables within Custom Indicators for more details on using the fmlvar() function.

Ambos, o nome da frmula e o nome da varivel devem estar contidos entre aspa (por exemplo, fmlvar ("Secret A", "MyVar")). Se voc mudar uma frmula ou nome de varivel, voc tambm tem que mudar qualquer as chamadas do fmvarl() que referncia aquela frmula e varivel. EXEMPLO fmlvar("MyIndicator", "MyVariableA" )

TAMBM VEJA Veja Referencing Variables within Custom Indicators para mais detalhes sobre o uso da funo fmlvar().

SINTAXE - Formula Variable Call (Frmula de Chamada de Varivel) 22/08/2008 12/12

Você também pode gostar