Announcement

Collapse
No announcement yet.

Kama

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

  • Kama

    Dear sirs,

    I have a problem with KAMA efs in real time (The efs for KAMA is joined) !

    I need to re-load manually every 10 minutes because it's not updating it self in real time!

    Is there something to do in the formula to correct the problem?

    Kind regards
    Attached Files

  • #2
    pbereau
    There are several errors in that formula. Starting from the top the following variables which are currently declared as local variables
    PHP Code:
    var AMA 0;
    var 
    diff 0
    should be declared as global variables [ie outside of function main()] as they need to maintain their values between iterations of the efs. You need to move them to the line below var AMA_1 = 0;
    Then the following section of code
    PHP Code:
    diff Math.abs(close() - close(-1));
    if (
    getBarState() == BARSTATE_NEWBAR){
        for(
    period 10i--)
            
    vnoise[i] = vnoise[1];
        
    vnoise[0] = diff;
     } 
    needs to be reversed as follows
    PHP Code:
    if (getBarState() == BARSTATE_NEWBAR){
        for(
    period 10i--)
            
    vnoise[i] = vnoise[1];
        
    vnoise[0] = diff;
     }
    diff Math.abs(close() - close(-1)); 
    else vnoise will be assigned the incorrect values. Lastly the following section of code
    PHP Code:
    AMA AMA_1 smooth * (close() - AMA_1);
    if (
    getBarState() == BARSTATE_NEWBAR)
        
    AMA_1 AMA
    should also be reversed as follows
    PHP Code:
    if (getBarState() == BARSTATE_NEWBAR)
        
    AMA_1 AMA;
    AMA AMA_1 smooth * (close() - AMA_1); 
    so that the variable AMA_1 gets assigned the value of AMA prior to the latter being calculated.
    Once you implement these changes the formula should function without having to reload it constantly.
    Alex

    Comment


    • #3
      Great Alex ! It works!! Thanks a lot!

      Comment


      • #4
        pbereau
        You are most welcome
        Alex

        Comment

        Working...
        X