Announcement

Collapse
No announcement yet.

Function Parameter Class

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

  • Function Parameter Class

    Hi,

    I'm trying to understand the Function Parameter Class.

    Please can you help me understand what is happening in this piece of code:

    var fp2 = new FunctionParameter("nStopAmt", FunctionParameter.NUMBER);
    fp2.setName("Stop Target Amount");
    fp2.setLowerLimit(0.01);
    fp2.setDefault(0.25);
    }

    In the body of the program, when a trade is opened, a stop level is set as follows:

    if (nNewTrade == 1) { //Execute New Trade
    // new or reversed trade position
    if (Strategy.isInTrade() == true) {
    if ((nsignal > 0) && (Strategy.isShort() == true)) {
    Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR);
    Strategy.doLong("Rev Long", Strategy.MARKET, Strategy.NEXTBAR);
    nStopLevel = low(-1) - nStopAmt;
    }
    if ((nsignal < 0) && (Strategy.isLong() == true)) {
    Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR);
    Strategy.doShort("Rev Short", Strategy.MARKET, Strategy.NEXTBAR);
    nStopLevel = high(-1) + nStopAmt;
    }
    } else {
    if ((nsignal > 0)) {
    Strategy.doLong("Go Long", Strategy.MARKET, Strategy.NEXTBAR);
    nStopLevel = low(-1) - nStopAmt;
    }
    if ((nsignal < 0)) {
    Strategy.doShort("Go Short", Strategy.MARKET, Strategy.NEXTBAR);
    nStopLevel = high(-1) + nStopAmt;
    }
    } // end if IN TRADE
    } // END EXECUTE NEW TRADE

    My question is, what is the value afforded to nStopAmt by the code. I don't understand the

    fp2.setLowerLimit(0.01);
    fp2.setDefault(0.25);

    part of the Function Parameter Class.

    Thanks in advance for your help.

    Neil.


  • #2
    Neil
    The value will be whatever you will type in the Stop Target Amount box in Edit Studies.
    fp2.setLowerLimit(0.01); is the lowest value you will be able to use as a variable.
    fp2.setDefault(0.25); is the default value assigned to that variable.
    You can find more information on Function Parameter Class in this article in the EFS KnowledgeBase
    Alex

    Comment


    • #3
      Great - thanks Alex.

      Neil

      Comment

      Working...
      X