Announcement

Collapse
No announcement yet.

No bars printing!

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

  • No bars printing!

    Can someone pls tell me what I have done wrong here? I have no bars printing in my indicator pane!!! I do have the value RETURNed to my cursor window, however, but not a bar in the pane!
    Thanks
    GP
    function preMain(){ setPriceStudy(false); setStudyTitle("Up/Dn Vol"); setCursorLabelName("Up/Dn Vol"); setDefaultBarFgColor(Color.green); setStudyMin(20); setStudyMax(299); addBand(100, PS_SOLID, 2, Color.black,"equalvolume"); var fp0 = new FunctionParameter("market", FunctionParameter.STRING); fp0.setName("Market"); fp0.addOption("NYSE"); fp0.addOption("NASDAQ"); fp0.setDefault("NYSE"); } var volRatio; function main(market){ if (market=="NYSE") {volRatio=((close("$UVOL")/close("$DVOL"))*100).toFixed(2);} else {volRatio=((close("$UVOLQ")/close("$DVOLQ"))*100).toFixed(2);} if (volRatio < 100) {setBarFgColor(Color.red,0);} return new Array (volRatio); }
    Last edited by wombat953; 09-03-2003, 09:59 AM.

  • #2
    Hello GP,

    The .toFixed() method returns a string. If you return a string to the chart, the value will appear in the cursor window but will not be drawn on the chart. To convert your volRatio variable back to a number, just multiply the result by 1.

    PHP Code:
    function preMain() { 
        
    setPriceStudy(false); 
        
    setStudyTitle("Up/Dn Vol"); 
        
    setCursorLabelName("Up/Dn Vol"); 
        
    setDefaultBarFgColor(Color.green); 
        
    setStudyMin(20); 
        
    setStudyMax(299); 
        
    addBand(100PS_SOLID2Color.black,"equalvolume"); 

        var 
    fp0 = new FunctionParameter("market"FunctionParameter.STRING); 
        
    fp0.setName("Market"); 
        
    fp0.addOption("NYSE"); 
        
    fp0.addOption("NASDAQ"); 
        
    fp0.setDefault("NYSE"); 


    var 
    volRatio

    function 
    main(market) {
        if (
    market == "NYSE") {
            
    volRatio = ((close("$UVOL")/close("$DVOL"))*100).toFixed(2)*1;
        } else {
            
    volRatio = ((close("$UVOLQ")/close("$DVOLQ"))*100).toFixed(2)*1;
        } 

        if (
    volRatio 100) {
            
    setBarFgColor(Color.red,0);
        }

        return 
    volRatio

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Jason - as always, many thanks. Altho' I m not sure I can say that this is completely intuitive! However, it is indeed in the JAVA doco!
      "The Number.prototype.toFixed method returns a string representing a Number object in fixed-point notation, rounded to the number of digits after the decimal point specified by fractionDigits."

      I did run across some code - posted here recently as part of a long thread- regarding TICK/TICKI readings, and was baffled why the author also used the "*1". There is no "tofixed" in this code. Or is he just being extra careful?
      Thanks
      George
      cT = close(0, 1, "$tick")*1;
      var cTi = close(0, 1, "$ticki")*1;
      var cTi_l = low(0, 1, "$ticki")*1;
      var cTi_h = high(0, 1, "$ticki")*1;
      if (cT == null || cTi == null || cTi_l == null || cTi_h == null) return;
      Last edited by wombat953; 09-03-2003, 02:33 PM.

      Comment


      • #4
        Hello GP,

        That's a little coding trick I use to convert the result of those calls to a number. The actual result of close(0, 1, "$tick") is an array of size 1. The proper way to return the result to the chart would be to reference the array number. For example, if you removed the *1, then instead of referencing cT throughout the formula, you would reference it as cT[0]. In the return statement at the end of main() you would then need to change cT to cT[0].

        Here's another handy trick that's kind of related to the above example. Notice the +"" in the last return statement of the formula you're referring to? barH and barL are numbers, but I didn't want to return the value to the chart if sOption was "Hist." Adding the +"" to barH and barL converts those variables to strings, which allows the values to be displayed in the cursor window but not drawn on the chart.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Jason - so you are saying that a string variable cannot - and will not - be returned to the chart in a separate pane, ever. And that this might be a desirable course of action, at some times.
          What about string variables in the body of the chart proper (with the price data)?
          Thanks
          George
          Last edited by wombat953; 09-03-2003, 06:01 PM.

          Comment


          • #6
            Hello George,

            You get the same behavior for price studies.
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment

            Working...
            X