Announcement

Collapse
No announcement yet.

Please Help! Code Errors

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

  • Please Help! Code Errors

    I wrote the following peice of code, which include a piece from dloomis, to basically return the high and low for the pre 900am cst hour. when I run it on a chart I get the following error...

    line 25: ReferenceError: getvalue is not defined


    I know it is something stupid, but I can't figure it out, and it is driving me nuts... Thanks in advance..


    function preMain() {
    setStudyTitle("9:00 High/Low");
    setCursorLabelName("9:00 High/Low");
    setPriceStudy(true);
    }
    /*
    * This function returns a High and low for the pre nine o'clock hour
    *
    */
    function main() {
    var nHigh = 0;
    var nLow = 0;
    var i;
    var interval;
    var indexer;
    var hValue;
    var lValue;
    indexer = (30 / interval);
    interval = getInterval();
    getTime();


    if(cTimeInt == 90000){
    hValue = getValue("High",0,-indexer); //line 25
    lValue = getValue("Low",0,-indexer);

    //get the high for the first half hour

    for(i=0; i<indexer-1; i++){
    if(hValue[i] >= nHigh){
    nHigh = hValue[i];
    }
    break;
    }

    //get the low for the first half hour

    for (i = 0; i<indexer-1; i++){
    if(lValue[i] <= nLow){
    nLow = lValue[i];
    }
    break;
    }


    drawTextRelative(1, 80, "High is" + nHigh + "Low is" + nLow, Color.black, Color.red, Text.FRAME | Text.ONTOP | Text.BOLD, null, null, "OS");
    }
    }
    /* This routine returns the following:

    CurYr, Current year, YYYY
    CurMon, Current month, MM
    CurDay, Current Day, DD

    cDateInt, Current Date, YYYYMMDD
    cDatePrint, Current date YYYY:MMD

    CurHr, Current Hour, HH
    CurMin, Current Minute, MM
    CurSec, Current Seconds, SS

    cTimeInt, Current Clock Time, HHMMSS
    cTimePrint, Current Clock Time, HH:MM:SS

    BarYr, Current Bar Year, YYYY
    BarMon, Current BAr Month, MM
    BarDay, Current Bar Day, DD

    BarYrMonDayInt, YYYYMMDD
    BarYrMonDayPrint, YYYY:MMD

    BarHr, Current Bar Hour, HH
    BarMin, Current Bar Minute
    BarSec, Current bar Seconds, SS

    cBarTimeInt, Current Bar Time, HHMMSS
    cBarTimePrint, Current Bar Time, HH:MM:SS
    */

    function getTime(){

    today =new Date;

    CurYr= today.getYear()+1900;
    if(CurYr<10){
    CurYr="0"+CurYr;}

    CurMon= today.getMonth()+1;
    if(CurMon<10){
    CurMon="0"+CurMon;}

    CurDay= today.getDate();
    if(CurDay<10){
    CurDay="0"+CurDay;}

    cDateInt =CurYr*10000+CurMon*100+CurDay*1;
    cDatePrint=CurYr+":"+CurMon+":"+CurDay;

    CurHr =today.getHours();
    if(CurHr<10){
    CurHr="0"+CurHr;}

    CurMin =today.getMinutes();
    if(CurMin<10){
    CurMin="0"+CurMin;}

    CurSec =today.getSeconds();
    if(CurSec<10){
    CurSec="0"+CurSec;}

    cTimeInt =CurHr*10000+CurMin*100+CurSec*1;
    cTimePrint=CurHr+":"+CurMin+":"+CurSec;

    BarYr = getValue("Year");
    if(BarYr<10){
    BarYr="0"+BarYr;}

    BarMon = getValue("Month");
    if(BarMon<10){
    BarMon="0"+BarMon;}

    BarDay = getValue("Day");
    if(BarDay<10){
    BarDay="0"+BarDay;}

    BarYrMonDayPrint= BarYr+":"+BarMon+":"+BarDay;
    BarYrMonDayInt= BarYr*10000+BarMon*100+BarDay*1;

    BarHr = getHour();
    if(BarHr<10){
    BarHr="0"+BarHr;}

    BarMin = getValue("Minute");
    if(BarMin<10){
    BarMin="0"+BarMin;}

    BarSec = getValue("Second");
    if(BarSec>=1&&BarSec<10){
    BarSec="0"+BarSec;}

    cBarTimePrint=BarHr+":"+BarMin+":"+BarSec;
    cBarTimeInt =BarHr*10000+BarMin*100+BarSec*1;
    return new Array(BarYrMonDayInt, BarYrMonDayPrint, BarYr, BarMon, BarDay, BarHr, BarMin, BarSec, cBarTimeInt, cBarTimePrint,cTimeInt,cTimePrint,cDateInt,cDatePr int, CurYr, CurMon, CurDay, CurHr, CurMin, CurSec);

    }

  • #2
    Hello mcoltd,

    I wasn't quit sure how to fix your code so I wrote a new formula using different methods. Take a look at the chart below and let me know if this is close to what you had in mind.



    PHP Code:
    function preMain() {
        
    setStudyTitle("9:00 High/Low");
        
    setCursorLabelName("9:00 High"0);
        
    setCursorLabelName("9:00 Low"1);
        
    setPriceStudy(true);
        
    //setStudyMax(10);
        //setStudyMin(0);
    }

    var 
    vFlag true;
    var 
    vHigh null;
    var 
    vLow null;
    var 
    vDay1 null;
    var 
    vDay2 null;

    function 
    main() {
        var 
    nState getBarState();

        
        if (
    nState == BARSTATE_NEWBAR) {
            if (
    vDay1 == null) {
                
    vDay2 getDay();
            } else {
                
    vDay2 vDay1;
            }
            
    vDay1 getDay();
            if (
    vDay1 != vDay2) {
                
    vHigh null;
                
    vLow null;
                
    vFlag true;
            }
            var 
    vHour getHour();
            if (
    vHour >= 9) {
                
    vFlag false;
            }
        }
        
        if (
    vFlag == true) {
            if (
    vHigh == null) {
                
    vHigh high();
            }
            if (
    vLow == null) {
                
    vLow low();
            }
            
    vHigh Math.max(high(), vHigh);
            
    vLow Math.min(low(), vLow);
        }
        
        
    drawTextRelative(-2vHigh"High is " vHigh "  Low is " vLowColor.blackColor.redText.FRAME Text.ONTOP Text.BOLD Text.RIGHT Text.TOPnullnull"OS");
        return new Array(
    vHighvLow);

    Attached Files
    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
      thanks

      hey man, thanks a lot, gues my code was way off.... anyway, if I have more questions I'll post...

      Comment

      Working...
      X