Announcement

Collapse
No announcement yet.

Defining Values

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

  • Defining Values

    I am having problems getting the following efs to work properly. As it is now, when the button is clicked, the colors are not defined. If the button function is moved within the main function, then the button function is not defined. Thank you in advance. Charley

    PHP Code:
    var nButtonPressed false;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Line");
        
    setShowCursorLabel(false);
        
        var 
    fp1 = new FunctionParameter("nMin"FunctionParameter.NUMBER);
            
    fp1.setName("Number of Minutes");
            
    fp1.setLowerLimit(1);
            
    fp1.setDefault(15);
        
        var 
    fp2 = new FunctionParameter("nFont"FunctionParameter.STRING);
            
    fp2.setName("Font");
            
    fp2.setDefault("Arial");
        
        var 
    fp3 = new FunctionParameter("nFontSize"FunctionParameter.NUMBER);
            
    fp3.setName("Font Size")
            
    fp3.setLowerLimit(6);        
            
    fp3.setDefault(12);

        var 
    fp4 = new FunctionParameter("aColor"FunctionParameter.COLOR);
            
    fp4.setName("Color");
            
    fp4.setDefault(Color.RGB(0,225,0));

        var 
    fp5 = new FunctionParameter("bColor"FunctionParameter.COLOR);
            
    fp5.setName("Color");
            
    fp5.setDefault(Color.RGB(225,0,0));
            
        var 
    fp6 = new FunctionParameter("BuColor"FunctionParameter.COLOR);
            
    fp6.setName("Button Color");
            
    fp6.setDefault(Color.RGB(35,35,35));    
    }
    var 
    vStartTime null;
    var 
    vHigh null;
    var 
    vLow null;
    var 
    vOpen null;
    var 
    vClose null;
    var 
    FirstBar null;

    function 
    main(nMinnFontnFontSizeaColorbColorBuColor) {
        
        if (
    getDay() != getDay(-1) || vHigh == null || vLow == null || vOpen == null || vClose == null) {
            
    vStartTime getValue("Time");
            
    vHigh high();
            
    vLow low();
            
    vOpen open();
            
    vClose close();
        }
        
    FirstBar getFirstBarIndexOfDay(vStartTime);
        var 
    vTime getValue("Time");

        if ((
    vTime vStartTime) / 60000 nMin) {                 // 3,600,000 milliseconds = 1 hour
            
    vHigh Math.max(high(), vHigh);                     //    60,000 milliseconds = 1 minute
            
    vLow Math.min(low(), vLow);
        }
            
    drawTextPixel(800"Reverse" "@URL=EFS:Button1"aColorBuColorText.RELATIVETOLEFT Text.RELATIVETOBOTTOM Text.CENTER Text.VCENTERnFontnFontSize"Bu1"8024);

        if (
    FirstBar != null) {
            if (
    vOpen vClose) {
                
    drawLineRelative(FirstBarvHigh0vHighPS_SOLID1aColor"High");
                
    drawLineRelative(FirstBarvLow0vLowPS_SOLID1bColor"Low");
            }
            if (
    vOpen vClose) {
                
    drawLineRelative(FirstBarvHigh0vHighPS_SOLID1bColor"High");
                
    drawLineRelative(FirstBarvLow0vLowPS_SOLID1aColor"Low")
            }
        }
    }
    function 
    Button1(nButtonPressed) {
        if (
    getButtonPressed(nButtonPressed) == 1) {
            
    drawLineRelative(FirstBarvHigh0vHighPS_SOLID1bColor"High");
            
    drawLineRelative(FirstBarvLow0vLowPS_SOLID1aColor"Low")
        } 
    }
    function 
    getButtonPressed(nButtonPressed) {
        
        if (
    nButtonPressed == BUTTON_LEFT) {
            return(
    1);
        }
        else {
            return(
    0);
        }


  • #2
    I changed the button function to the following:

    PHP Code:
    function Button1(nButtonPressedaColorbColor) {
        if (
    getButtonPressed(nButtonPressed) == 1) {
            
    drawLineRelative(FirstBarvHigh0vHighPS_SOLID1bColor"High");
            
    drawLineRelative(FirstBarvLow0vLowPS_SOLID1aColor"Low")
        } 

    Now it is no longer saying that the color is undefined, but states that function parameter #7, which is the color, is invalid.

    Comment


    • #3
      Sorry to be a pain. The high and low values are correct, but I am also trying to return the value of the close after the first 15 minutes with the vClose variable but the formula output is only showing object series
      Thanks.

      Comment


      • #4
        Hi! I'm back. I have worked out the button function issue, but am still having a problem with the vClose value. This efs returns the High and Low values after the opening 15 minutes. I am also trying to return the current value. If I am using a 10 min chart, the close value will not work, because after 15 min. I am in the middle of a 10 min bar. Any suggestions?

        Comment


        • #5
          Consider using "getBarStateInterval( interval ) "

          Wayne

          Comment


          • #6
            Thanks Wayne

            Comment

            Working...
            X