Announcement

Collapse
No announcement yet.

Syntax Error From Back Testin

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

  • Syntax Error From Back Testin

    Hi Guys,

    I keep getting the following error in my back testing.

    Line 28 SyntaxError: Missing ; before statement : var vMACD12_26.getValue (MACDStudy.SIGNAL);

    I have included the part of the code to which it is reffering to.

    26 function main(nProfitAmt, nStopAmt){
    27 ProfitTarget1 = nProfitAmt;
    28 var vMACD12_26.getValue (MACDStudy.SIGNAL);
    29 var vMACD12_26.getValue (MACDStudy.MACD);
    30 var vRSI14.getValue (vRSIStudy.RSI);
    31 var vEMA40.getValue (MAStudy.MA);
    32 var vEMA12.getValue (MAStudy.MA);
    33 var vEMA26.getValue (MAStudy.MA);
    34 if (Strategy.isInTrade()==true && (nNewTrade == 1)){
    35 nNewTrade = 0;
    36 }

    Can anyone help?

    Thanks
    Harry

  • #2
    Harry
    You are missing the name of the variable to which you will assign the value. For example
    var myVar = vMACD12_26.getValue(MACDStudy.SIGNAL);
    The same error is present in the other lines you are showing
    Alex

    Comment


    • #3
      Hi Alex

      So would this code make more sense?

      var study1 = new MACDStudy(12, 26, 9, "Close", false, false);
      var study2 = new RSIStudy (14, "Close");
      var study3 = new MAStudy (40, 0, "Close", MAStudy.EXPONENTIAL);
      var study4 = new MAStudy (12, 0, "Close", MAStudy.EXPONENTIAL);
      var study5 = new MAStudy (26, 0, "Close", MAStudy.EXPONENTIAL);

      function preMain(){
      setPriceStudy(true);
      setStudyTitle("TradingModel1");
      var fp1 = new FunctionParameter("nProfitAmt", FunctionParameter.NUMBER);
      fp1.setName ("Profit Target Amount");
      fp1.setLowerLimit (0.01);
      fp1.setDefault(5)

      var fp2 = new FunctionParameters("nStopAmt", FunctionParameter.NUMBER);//Stop Features
      fp2.setName("Stop Target Amount");
      fp2.setLowerLimit(0.01);
      fp2.setDefault(3);
      }
      function main(nProfitAmt, nStopAmt){
      ProfitTarget1 = nProfitAmt;
      var vMACD = study1.getValue (MACDStudy.SIGNAL);
      var vMACD = study1.getValue (MACDStudy.MACD);
      var vRSI = study2.getValue (vRSIStudy.RSI);
      var vEMA = study3.getValue (MAStudy.MA);
      var vEMA = study4.getValue (MAStudy.MA);
      var vEMA = study5.getValue (MAStudy.MA);
      if (Strategy.isInTrade()==true && (nNewTrade == 1)){
      nNewTrade = 0;
      }

      Cheers

      Comment


      • #4
        Harry
        Not really. You are assigning different values to the same variables.
        You should have something more like the following
        var vMACDSig = study1.getValue (MACDStudy.SIGNAL);
        var vMACD = study1.getValue (MACDStudy.MACD);
        etc

        Alex

        Comment

        Working...
        X