Announcement

Collapse
No announcement yet.

Force Index

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

  • Force Index

    Hi

    I have downloaded the attached efs from the bulletin board. I am trying to understand efs and java - can anyone explain the following

    why the variable XA_1 and XA1_1 are set to zero and then used in the main function area without apparently being changed?
    I must be missing something but it has been bugging me!

    Secondly how is the moving average plotted? I only see histogram outputs?

    Any help much appreciated .
    Attached Files

  • #2
    Solution...

    Read my comments in the code below. I think they will help to explain what this code is doing.

    Brad


    PHP Code:
    /*******************************************************************
    Description    : This Indicator plots Force Index indicator
    Provided By    : Developed by TS Support, LLC for eSignal. (c) Copyright 2002 
    ********************************************************************/

    function preMain()
      {
        
    setStudyTitle("Force Index");
        
    setCursorLabelName("FI Sm"0);
        
    setCursorLabelName("SlowAvg"1);
        
    setCursorLabelName("Zero"2);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.blue1);
        
    setDefaultBarFgColor(Color.green2);
    // the line below designates that item 0 is a HISTOGRAM, the other items (1 and 2) default
    // to a LINE.
        
    setPlotType(PLOTTYPE_HISTOGRAM0);
    }

    // global variables use to remember the last XA1 adn XA2 values for the next instance of the main() function.
    var XA1_1 0.0;
    var 
    XA2_1 0.0;

    function 
    main(XLen1XLen2){
        if (
    XLen1 == nullXLen1 3;
        if (
    XLen2 == nullXLen2 13;

        
        var 
    Volume getValue("Volume"0);
        var 
    Close getValue("Close"0, -2);
        var 
    FrceIdx Volume * (Close[0] - Close[1]);
        var 
    Factor1 / (XLen1 1);
        var 
    Factor2 / (XLen2 1);
        
    // the two lines below use the previous bars value of XA1_1 adn XA2_1 to 
        // calculate the new bars indicator values.
        
    var XA1 Factor1 FrceIdx + (Factor1) * XA1_1;
        var 
    XA2 Factor2 FrceIdx + (Factor2) * XA2_1;
        

       if (
    getBarState() == BARSTATE_NEWBAR
        
    //  At this point, the current XA1 and XA2 are stored to the global variables for use the next time
        // this indicator is calculated.
            
    XA1_1 XA1;
            
    XA2_1 XA2;
        
        if (
    XA1>0){
        
    setBarThickness(2);
        
    setBarFgColor(Color.lime);
        }
        if (
    XA1<0){
        
    setBarThickness(2);
        
    setBarFgColor(Color.red);
        }
        
        return new Array(
    XA1XA20);

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      RE: Reply to post 'Force Index'

      Right - so the global variables are only ever zero on the very first
      iteration?
      And the line/histogram - how does the efs know what is item 0,1, 2 etc

      -----Original Message-----
      From: [email protected] [mailto:[email protected]]
      Sent: Friday, June 27, 2003 8:07 AM
      To: [email protected]
      Subject: Reply to post 'Force Index'


      Hello Russell,

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      Comment


      • #4
        wasn't this is S&C? Does anyone know which issue?

        Comment

        Working...
        X