Announcement

Collapse
No announcement yet.

Programming help

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

  • Programming help

    Could someone please help with the following:-
    1. I would like the background color to change from cyan to magenta when the value of "R1" is a particular value +/- 2.
    nX = inputXstart;
    nY -= nFontCY;
    drawTextPixel(nX, nY, R1, Color.black, Color.cyan,
    Text.FRAME | Text.CENTER | Text.VCENTER | Text.BOLD,
    null, nFontSize, "r3c1", nColWidth, nRowThickness);

    2. If I have 2 values in 2 separate efs's, can I display the Total value in a third efs ? I think I have to use the efsExternal() function, but I am not sure how to do it.

    Any help would be greatly appreciated.

    Eric

  • #2
    Eric
    With regards to changing the color based on a condition you could do it as shown in the enclosed example
    Alex

    PHP Code:
    if(R1 <= myValue+&& R1 >= myValue-2){
        var 
    myColor Color.magenta;
    }else{
        var 
    myColor Color.cyan;
    }
    drawTextPixel(nXnYR1Color.blackmyColor,
                 
    Text.FRAME Text.CENTER Text.VCENTER Text.BOLD,
                 
    nullnFontSize"r3c1"nColWidthnRowThickness); 

    Comment


    • #3
      Eric
      With regards to your second question you can use efsExternal() if the values you want to retrieve are being returned by those efs(s).
      For the syntax required by that efsExternal() function see this article in the EFS KnowledgeBase
      You can also find several examples in this thread which is specifically dedicated to the efsExternal() and efsInternal() functions and in this thread which includes some examples of studies on studies that use the efsExternal() function.
      Alex

      Comment


      • #4
        Hello Alex,

        Thank you for taking the time to reply.
        I'll work through the efsExternal code over the weekend.
        I still have a problem with the first part.
        I am trying to get the cell to change color when ES #F=2 falls between a level "L1" +/- 10 as set in 'Edit Studies'.
        It works if I put in a numerical value in place of the symbol code in 'Edit Studies'.
        Also I would like to add audio alerts as well.
        Thank you for your patience !!

        Eric
        Attached Files

        Comment


        • #5
          Eric
          The logic used in the condition that colors the cell is incorrect. Translating it into plain language
          if(L1 <= (ES+10) && L1 >= (ES-10))
          reads as follows
          "if L1 is less than or equal to "ES #F=2,D" + 10 and L1 is greater than or equal to "ES #F=2,D" - 10"
          Note that "ES #F=2,D" is a string and not a value or a price series and will concatenate with +10 resulting in the string "ES #F=2,D10" while it will return NaN (ie Not a Number) when you subtract 10 from it. To verify this just add a debugPrintln(ES+10) or debugPrintln(ES-10) before the condition and you will see what I am referring to.
          As L1 (set to 1280 by default) is never greater, lesser or equal to any of those strings the cell will be always colored in cyan as the condition that would color it in magenta is never true.
          You need to assign the symbol to a price series such as for example close(). In this case you would write
          if(L1 <= (close(ES)+10) && L1 >= (close(ES)-10)){
          which will paint the cell in magenta if the condition evaluates to true.
          Alex

          Comment


          • #6
            Hello Alex,

            Thank you for the detailed explanation - I totally overlooked the logic.
            I really appreciate the time you have taken to help me out.

            Eric

            Comment


            • #7
              Eric
              You are most welcome
              Alex

              Comment

              Working...
              X