Announcement

Collapse
No announcement yet.

Draw Text in efs studies

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

  • #16
    An if then with 2 equation

    i tried a variation of the close open difference, but I can't get it to draw x.

    The logic is if the current open is more than 2 points from previous close then x is open +1 if current open is less than previous close and open -1 if current open is greater than precious close

    PHP Code:
    if (close(-1) - open(0)  >= 2){
        
    open(0) +1;
    }
    if (
    open(0) - close (-1) >= 2){
       
    open(0) -1;

    }else{
      
    xnull;

    Now do these have to be 2 different if then else statements and can these be converted to Ternary operator.

    I tried the following but it did not work.

    PHP Code:

    open(0) - close(-1) >= open(0) - null;
    close(-1) - open (0) >=open(0) + 1null

    Comment


    • #17
      akiri
      Enclosed below is an example of how you could write that conditional statement.
      Then depending on whether you want the value of x to persist between iterations of the efs or not you would need to declare x as a global variable (ie outside of the preMain() and main() functions) or local variable (ie inside the main() function).
      Alex

      Comment


      • #18
        Persistance Between Iterations

        Alexis thanks again.

        Could u clarify by what u mean as " persistance between iterations" or when should x be global as opposed to local or what is the advantage of x being global.

        Thanks

        AK

        Comment


        • #19
          akiri
          A global variable remains in memory between executions of an efs while a local variable is reinitialized at each execution. Which one you need to use depends on what you need to do with that variable.
          To learn more about these basic programming concepts I would suggest that you review the JavaScript for EFS videos and the Core JavaScript Reference Guide. Those will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with the specifics of EFS.
          Alex

          Comment

          Working...
          X