Announcement

Collapse
No announcement yet.

can't get background color to work

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

  • can't get background color to work

    I'm a complete coding idiot. Can someone tell me why the setbgcolor statement in the main function won't color my chart properly? Thanks in advance.

    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description 7532


    //{{EFSWizard_Declarations

    var vCCI14_of_HLC3 = new CCIStudy(14, "HLC/3");
    var vCCI6_of_HLC3 = new CCIStudy(6, "HLC/3");
    var vLastAlert = -1;

    //}}EFSWizard_Declarations 14566


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(false);
    setStudyTitle("RHbobscci");
    setCursorLabelName("CCI14", 0);
    setCursorLabelName("CCI6", 1);
    setCursorLabelName("histo",2);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.black, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarFgColor(Color.black,2);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(1, 1);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);
    setPlotType(PLOTTYPE_HISTOGRAM, 2);
    //}}EFSWizard_PreMain 53579

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    //}}EFSWizard_Expression_1 0

    //}}EFSWizard_Expressions 9063
    //my personal additions
    addBand(200,PS_SOLID,1,Color.black,1);
    addBand(-200,PS_SOLID,1,Color.black,2);
    addBand(0,PS_SOLID,1,Color.black,3);

    //This section is to add in bells and whistles
    if (vCCI14_of_HLC3 >= 10 ) {
    setBarBgColor(Color.lime, 0);
    }
    //{{EFSWizard_Return
    return new Array(
    vCCI14_of_HLC3.getValue(CCIStudy.CCI),
    vCCI6_of_HLC3.getValue(CCIStudy.CCI),
    vCCI14_of_HLC3.getValue(CCIStudy.CCI)
    );
    //}}EFSWizard_Return 15203

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1 5589

    //}}EFSWizard_Actions 15622

  • #2
    coolmoss
    Replace the following line
    if (vCCI14_of_HLC3 >= 10 ) {
    with
    if (vCCI14_of_HLC3.getValue(CCIStudy.CCI) >= 10 ) {
    Alex

    Comment


    • #3
      Alexis,

      Thank you much. As I"m trying to understand and learn how to code better, can you explain how a person figures out what you told me. I"ve read the javascript manuals online and several books and the esignal info. None of it that I can recall or find mentions this little tweak.

      How could I have figured this out. I'm trying to make sense out of why the variable was declared one way and then used with completely different syntax.

      Would it have made a difference if I created another variable like "vMyVariable", assigned it the value and just referenced vMyVariable, or what?

      Thanks so much for any comments. Anythings gotta help a bit at this point.

      Comment


      • #4
        coolmoss

        I'm trying to make sense out of why the variable was declared one way and then used with completely different syntax.

        In creating the variable vCCI14_of_HLC3 in line 10 of the efs you are just declaring an object of CCIStudy() and assigning all the functions and properties of that object to that variable.
        Using vCCI14_of_HLC3 alone to retrieve the CCI value is not enough because that is only an object hence you have to use the getValue() command. That is where vCCI14_of_HLC3.getValue(CCIStudy.CCI) comes into play. The CCIStudy.CCI part in the command is referencing a variable inside of the CCIStudy object.
        In this case the variable is only one but if for example you were using the ADX object you would have three variables ie ADXDMStudy.ADX, ADXDMStudy.PDI and ADXDMStudy.NDI.

        How could I have figured this out

        Actually that information is provided in the Builtin Study Functions.section under EFS Function Reference in the EFS Help Center & Library.
        Also if you had used the Formula Wizard to create that conditional statement you would have seen that it would have used exactly the same syntax.
        Lastly if you look at the builtin efs(s) in the Builtin folders in Formulas you will see that in each one there is a comment section that provides the correct syntax to be used in the scripts.
        Alex

        Comment


        • #5
          Thank you!

          Alexis,

          This helps immensely. I keep trying to learn how to code but keep hitting stumbling blocks. As long as I'm patient and there are community members willing to answer, I keep making progress.

          Now, if only trading were coming along so well, LOL.

          Comment

          Working...
          X