Announcement

Collapse
No announcement yet.

keyboard input

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

  • keyboard input

    i'm trying to get a single value from keyboard when .efs is loaded.

    Function preMain() {
    setStudyTitle("breakout");
    set StudyMax(100);
    setStudyMin(0);
    askForInput("break price");
    }

    function main() {
    ....

    i never get the option to enter a price.
    i'm using latest ver 10.
    any help is appreciated...
    thanks,
    peter.

  • #2
    Re: keyboard input

    peter
    I think you are misunderstanding the function of askForInput() which is just to call a simplified Edit Studies dialog box in which you enter the values for the parameters defined using the FunctionParameter object.
    For an example of how this works see any one of the scripts included in the EFS2 Custom folder
    Alex


    Originally posted by peterjerome
    i'm trying to get a single value from keyboard when .efs is loaded.

    Function preMain() {
    setStudyTitle("breakout");
    set StudyMax(100);
    setStudyMin(0);
    askForInput("break price");
    }

    function main() {
    ....

    i never get the option to enter a price.
    i'm using latest ver 10.
    any help is appreciated...
    thanks,
    peter.

    Comment


    • #3
      alex,'
      thanks for the quick reply.

      i see now where the askForImput is not what i needed.
      i need a way to get a single numeric entry into an EFS file.

      is there another statement that will do this?
      thanks,
      peter.

      Comment


      • #4
        Hello,

        I have an efs that draws a button which when I click will draw a fixed support and fixed resistance levels on a chart. Now I would like to be able to advance this efs to the next stage by asking me to input the new Support & new Resistance Levels every time I click on this button. Would someone kindly suggest how I would go about doing it. Much appreciation for any help.

        Ted

        Comment


        • #5
          Hi Ted,

          As far as I know the only way for a user to input values including what you are asking about is through the "Edit Chart" menu via main() parameters. So if your efs doesn't have FunctionParameters for said support and resistance you would need to add them making sure they are also included in the main() parameter list and finally as values in the draw function used for the fixed support and resistance lines.

          A button executes code but I don't know of any user input other than what I explained above.

          Wayne

          Comment


          • #6
            Ted
            In the handler function called by the button add an askForInput() call which will open the Edit Chart (or a simplified input dialog if using version 10.6 or earlier)
            Alex


            Originally posted by Ted608 View Post
            Hello,

            I have an efs that draws a button which when I click will draw a fixed support and fixed resistance levels on a chart. Now I would like to be able to advance this efs to the next stage by asking me to input the new Support & new Resistance Levels every time I click on this button. Would someone kindly suggest how I would go about doing it. Much appreciation for any help.

            Ted

            Comment


            • #7
              Hi Wayne & ACM

              Thank you very much for taking the time to answer my question.
              I think I will try askForInput() for now.

              Ted.

              Comment


              • #8
                Ted, below is a bit of code that will draw a square on a chart if you right click on the top left hand corner, then the lower right hand corner. Perhaps you could pull bits from it, changing the line drawing to be what you want. I'm in the middle of trying to get the Volume at Price to draw within this box, and this is the reason I created it. (Self taught, so code may be sloppy.)

                Cheers

                var bInit = false;
                var nToplx = 0;
                var nToply = 0;
                var nBotlx = 0;
                var nBotly = 0;
                var nToprx = 0;
                var nTopry = 0;
                var nBotrx = 0;
                var nBotry = 0;
                var nQtyboxes = -1;
                var aBox = new Array(1,1);
                var nTick = 0;
                var sTick = 0;




                function preMain() {

                setPriceStudy(true);
                setStudyTitle("DrawSquare");
                setProperty( "HideEncryptedLock", "yes" );

                // addEntitlement( "http://www.kroll.id.au//xxxauthorizedusers.txt", "Initialization problem. Email [email protected]" );//,
                }
                function main()

                {
                if (bInit == false)
                {
                nTick = getMinTick();
                sTick = nTick.length;
                sTick = ""+nTick;
                //debugPrintln(sTick.length);
                var nPos = sTick.indexOf(".",0);
                sTick = sTick.substr(nPos+1,sTick.length-nPos ); //- 1
                nTick = sTick.length;
                //debugPrintln(nTick);
                bInit = true;
                }

                }

                function onRButtonDown( barIndex, yValue)
                {
                yValue = rnd(yValue,nTick);
                for(var i = 0; i < nQtyboxes; i++)
                {
                if (aBox[i,0] == barIndex && aBox[i,1] == yValue)
                {
                aBox[i,0] = 0;
                aBox[i,1] = 0;
                removeLine("A"+barIndex);
                removeLine("B"+barIndex);
                removeLine("C"+barIndex);
                removeLine("D"+barIndex);
                return null;
                }
                }


                if (nToplx != 0)
                {
                nBotrx = barIndex;
                nBotry = yValue;
                }
                if (nToplx == 0)
                {
                nToplx = barIndex;
                nToply = yValue;
                }

                if (nToplx != 0 && nBotrx != 0)
                {
                nToprx = nBotrx;
                nTopry = nToply;

                nBotlx = nToplx;
                nBotly = nBotry;

                drawLineRelative(nToplx,nToply,nToprx,nTopry,PS_SO LID,1,Color.black,"A"+nToplx);
                drawLineRelative(nBotlx,nBotly,nBotrx,nBotry,PS_SO LID,1,Color.black,"B"+nToplx);
                drawLineRelative(nToplx,nToply,nBotlx,nBotly,PS_SO LID,1,Color.black,"C"+nToplx);
                drawLineRelative(nToprx,nTopry,nBotrx,nBotry,PS_SO LID,1,Color.black,"D"+nToplx);
                nQtyboxes ++;
                aBox[nQtyboxes,0] = nToplx;
                aBox[nQtyboxes,1] = nToply;

                nToplx = 0;
                nToply = 0;
                nBotlx = 0;
                nBotly = 0;
                nToprx = 0;
                nTopry = 0;
                nBotrx = 0;
                nBotry = 0;

                }
                }
                function onLButtonDown( barIndex, yValue)
                {
                nToplx = 0;
                nToply = 0;
                nBotlx = 0;
                nBotly = 0;
                nToprx = 0;
                nTopry = 0;
                nBotrx = 0;
                nBotry = 0;
                }
                function rnd(value, N)
                {
                var n;
                var mult=1;
                for(n=0;n<N;n++) mult*=10;
                value*=mult;
                return Math.round( value,N)/mult;
                }
                Last edited by merkro; 07-31-2015, 03:30 AM.

                Comment

                Working...
                X