Announcement

Collapse
No announcement yet.

formula

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

  • formula

    hello,

    can anyone inform me of why I continually receive a syntax error pertaining to the following statement:

    var fullbuy=(var nclose-var nhigh)/var nhigh);

    Please note, I have tried eliminating the "var" in front of "full buy" and adding an additional "=".

    Thank you in advance.

    PB

  • #2
    usually var is used to declare variables before -- function main()
    ex. var fullbuy = 0;
    after that, just use the variable

    I think your main problem is any 'var' on the right side of =
    also you have 2 right ')', 1 left

    try
    fullbuy=((nclose- nhigh)/ nhigh); // but declare variables first

    Comment


    • #3
      Thx DZ for your input. It unfortunately did not fix my problem but I appreciate your input.

      PB

      Originally posted by DavidZ
      usually var is used to declare variables before -- function main()
      ex. var fullbuy = 0;
      after that, just use the variable

      I think your main problem is any 'var' on the right side of =
      also you have 2 right ')', 1 left

      try
      fullbuy=((nclose- nhigh)/ nhigh); // but declare variables first

      Comment


      • #4
        Hello PB,

        You may need to post the actual code you are working with so we can see what the specific problem may be.

        In the mean time, try this,

        var fullbuy = ( close(0) - high(0) ) / high(0) ;

        or this,

        var nclose = close(0);
        var nhigh = high(0);

        var fullbuy = ( nclose - nhigh) / nhigh;
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Response with code

          Hello Jason,

          The following is the code to date. I am aiming to develop a code that tracks my current position whether long/short and determine whether the subsequent moves, high or low, from that position is greater than 1.0%. Thx again.

          function preMain() {
          setPriceStudy(true)
          }


          function main() {

          nSignalHigh=high
          nSignalLow=low
          var3=.01;
          FullBuy=((close-nSignalHigh)/nSignalHigh>=var3);
          FullSell=((close-nSignalLow)/nSignalLow<=var3);

          if (Strategy.isInTrade()) {
          if ((FullBuy==true) && (Strategy.isShort())) {
          Strategy.doCover("ExitShort", Strategy.MARKET,Strategy.NEXTBAR);
          Strategy.doLong("RevLong",Strategy.MARKET,Strategy .NEXTBAR);
          Alert ("Full Buy");
          debugPrintln("Full Buy");
          }
          if ((FullSell==true)&&(Strategy.isLong()==true)) {
          Strategy.doSell("ExitLong",Strategy.MARKET,Strateg y.NEXTBAR);
          Strategy.doShort("RevShort",Strategy.MARKET,Strate gy.NEXTBAR);
          Alert("Full Sell");
          debugPrintln("Full Sell");
          }
          if ((FullBuy==true)&&(Strategy.isLong())) {
          Strategy.doLong("RevLong",Strategy.MARKET,Strategy .NEXTBAR);
          Alert("InterimBuy");
          debugPrintln("InterimBuy");
          }
          if ((FullSell=true)&&(Strategy.isShort())) {
          Strategy.doShort("RevShort",Strategy.MARKET,Strate gy.NEXTBAR);
          Alert("InterimShort");
          debugPrintln("InterimShort");
          }
          }
          }


          Originally posted by JasonK
          Hello PB,

          You may need to post the actual code you are working with so we can see what the specific problem may be.

          In the mean time, try this,

          var fullbuy = ( close(0) - high(0) ) / high(0) ;

          or this,

          var nclose = close(0);
          var nhigh = high(0);

          var fullbuy = ( nclose - nhigh) / nhigh;

          Comment


          • #6
            Hello PB,

            The code you have posted has many syntax and logic errors. Rather than go through each one for you here I recommend that you try to learn more about the basics of EFS and programming in JavaScript.

            To learn more about general programming in JavaScript (the foundation for EFS), please start with our JavaScript for EFS video series.

            Then move on to our Beginner Tutorials to learn about the specifics of EFS formula development. To learn more about creating back testing formulas, there are also a couple tutorials dedicated to this process, which can also be found at the link above.
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment

            Working...
            X