Announcement

Collapse
No announcement yet.

variable that will change according to the symbol

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • variable that will change according to the symbol

    How can I create variable that will change according to the symbol ?
    for example i want that when i am looking on Caterpillar (symbol CAT) the variable pr will be 7
    and when i look on Ford (symbol F) the variable pr will be 3.

    thanks in advance for the help


    ************************/
    function preMain() {

    setPriceStudy(true);
    setStudyTitle("test");
    setCursorLabelName("EnvUpr", 0);
    setCursorLabelName("EnvBas", 1);
    setCursorLabelName("EnvLwr", 2);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarFgColor(Color.blue, 2);
    setPlotType(PLOTTYPE_LINE,0);
    setPlotType(PLOTTYPE_LINE,1);
    setPlotType(PLOTTYPE_LINE,2);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    setDefaultBarThickness(1,2);
    }

    function main() {

    if (((sym("f") , pr = 3) || sym("cat"), pr = 7));



    return new Array (upperEnv(20,0,pr),middleEnv(20,0,10),lowerEnv(20, 0,10));
    }

  • #2
    Re: variable that will change according to the symbol

    bark
    Here is a basic example of what you would do
    Replace your conditional statement [which is incorrect in both its construct and in the usage of the functions]
    PHP Code:
    if (((sym("f") , pr 3) || sym("cat"), pr 7)); 
    with the following
    PHP Code:
    var pr 1;//declare the variable pr and assign to it some default value otherwise
               //when charting any other symbol the formula will return an error
    var mySymbol getSymbol();//declare the variable mySymbol and assign to it the chart's symbol
    if(mySymbol == "CAT") {
        
    pr 7;
    }
    else if(
    mySymbol == "F") {
        
    pr 3;

    Alex


    Originally posted by bark
    How can I create variable that will change according to the symbol ?
    for example i want that when i am looking on Caterpillar (symbol CAT) the variable pr will be 7
    and when i look on Ford (symbol F) the variable pr will be 3.

    thanks in advance for the help


    ************************/
    function preMain() {

    setPriceStudy(true);
    setStudyTitle("test");
    setCursorLabelName("EnvUpr", 0);
    setCursorLabelName("EnvBas", 1);
    setCursorLabelName("EnvLwr", 2);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarFgColor(Color.blue, 2);
    setPlotType(PLOTTYPE_LINE,0);
    setPlotType(PLOTTYPE_LINE,1);
    setPlotType(PLOTTYPE_LINE,2);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    setDefaultBarThickness(1,2);
    }

    function main() {

    if (((sym("f") , pr = 3) || sym("cat"), pr = 7));



    return new Array (upperEnv(20,0,pr),middleEnv(20,0,10),lowerEnv(20, 0,10));
    }

    Comment

    Working...
    X