Announcement

Collapse
No announcement yet.

Force Index

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

  • Force Index

    I am trying to get the chart background to change colour if the previous bars force index crosses 0

    have tried many variations sometimes work sometime not


    Jamie
    Attached Files

  • #2
    Jamie
    XA2 and XA2_1 are not arrays but the values of the Force Index at the current and prior bars respectively.
    Try changing the conditions to what is shown below and it should work
    Alex

    PHP Code:
    if (XA2 && XA2_1 0)
            
    onAction1();
        else if (
    XA2 && XA2_1 0)
            
    onAction2();
        else
            
    onAction3(); 

    Comment


    • #3
      So how would I get the value from 3 bars ago


      Jamie

      Comment


      • #4
        as I would like to fo this


        XA2 > 0 &&
        XA2_1 < XA2



        Jamie

        Comment


        • #5
          Jamie
          There are several ways to do it. If you are using the variable in your return you could use the ref() function. If not then you have two methods.
          The simplest one is to transfer the values at every new bar just like you are already doing inside the getBarState() condition in your script. So for example you would create two new global variables called XA2_2 and XA2_3 and in the getBarState() condition you would do the following

          PHP Code:
          if)getBarState()==BARSTATE_NEWBAR){
              
          XA2_3 XA2_2;
              
          XA2_2 XA2_1;
              
          XA2_1 XA2;

          If you have to retrieve historical bars beyond two or three bars back then you may want to look at creating an array to store the historical values. For information on arrays see this article in the EFS KnowledgeBase
          Alex

          Comment


          • #6
            Jamie
            With regards to arrays you may also want to look at the easyArray.efsLib function library which is discussed in this post and which simplifies the process of creating and maintaining arrays
            Alex

            Comment


            • #7
              Hi Alex

              you must get fed up with stupid people like me, have tried to calculate but the following doe not work



              Jamie
              Attached Files

              Comment


              • #8
                Jamie
                You applied the transfer of values inside the getBarState() condition in the opposite order to the one shown in my example. Try to implement it as I wrote it
                Alex

                Comment


                • #9
                  Thanks told you I was stupid,

                  If your ever in UK I will buy you lunch


                  Jamie

                  Comment


                  • #10
                    Jamie

                    you must get fed up ...

                    On the contrary. IMHO you reflect the spirit of this forum to the letter ie you write your own code and come to the board seeking help on specific programming issues. This is eactly what this forum is meant for.
                    Alex

                    Comment

                    Working...
                    X