Announcement

Collapse
No announcement yet.

Still no help.....NO Reponses...

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

  • Still no help.....NO Reponses...

    Please review thread..

    http://forum.esignalcentral.com/show...&threadid=5156

  • #2
    Ian
    I actually had already responded by providing you with the correct formula which - contrary to what you stated - is not the same as the one you posted.
    In fact here below you can see the results in real time of your formula and the one I posted
    Alex

    Comment


    • #3
      Yes you did reply, but still code does not work...painting bar and swing correctly...

      Looks like and exact match to me...

      function preMain() {
      setStudyTitle("IansMACD2");
      setDefaultBarFgColor(Color.red, 0); // MACD EMA
      setDefaultBarFgColor(Color.green, 1); // Signal Line

      setCursorLabelName("DiNapoli MACD", 0);
      setCursorLabelName("Signal Line", 1);
      setColorPriceBars(true);

      }

      var ema1 = 0;
      var ema2 = 0;
      var ema1_prev = 0;
      var ema2_prev = 0;
      var macd1 = 0;
      var macd1_prev = 0;
      var macdema = 0;
      var macdema_prev = 0;
      var SLine = 0;

      var sf1 = .213;
      var sf2 = .108;
      var sf3 = .199;

      var length1 = 8;
      var length2 = 18;
      var length3 = 9;

      var cntr = 0;
      var i = 0;

      function ema(nClose, nEma, nSF){
      var val = 0;
      if(nClose == null){
      return;
      }
      val = (nClose - nEma) * nSF + nEma;
      return val;
      }

      function main() {
      var nState = getBarState();
      cntr = cntr + 1;
      var P1 = getValue("Close");
      var P2 = getValue("Close", -1, 1);

      if (cntr == 18) {
      var sum = 0;
      var price = getValue("Close", 0, -length1);

      // get ema1;
      if(price == null){
      return;
      } else {
      for(i = 0; i < length1; i++) {
      sum += price[i];
      }
      ema1 = sum / length1;
      }
      ema1_prev = ema1;

      sum = 0;
      price = getValue("Close", 0, -length2);

      // get ema2;
      if(price == null) {
      return;
      } else {
      for(i = 0; i < length2; i++) {
      sum += price[i];
      }
      ema2 = sum / length2;
      }
      ema2_prev = ema2;
      } else if (cntr > 18) {
      if (nState == BARSTATE_NEWBAR) {
      ema1_prev = ema1;
      ema2_prev = ema2;
      macd1_prev = macd1;
      macdema_prev = macdema;
      }
      ema1 = ema(P1, ema1_prev, sf1);
      ema2 = ema(P1, ema2_prev, sf2);
      macd1 = ema1 - ema2;
      macdema = ema(macd1, macdema_prev, sf3);

      SLine = (macd1 - macd1_prev) * sf3 + macd1_prev;

      return new Array(macdema, SLine);

      //Paint Price Bars
      if(SLine<0)
      setPriceBarColor(Color.red);

      else if(SLine>0)
      setPriceBarColor(Color.blue);

      else if(1==1)
      setPriceBarColor(Color.black);


      } else {
      return;
      }
      }

      Comment


      • #4
        Ian
        FYI the code you enclosed here is not the same as the one you posted in the linked thread.
        Irrespective, to fix this efs simply move the conditions to paint the price bars to before the return newArray(macdema,SLine);
        Alex

        Comment


        • #5
          Digs,

          In the code you posted, the Paint Price Bars section is after the return new Array() function. This would cause the painting of the price bars to not function as expected, and is the likely cause of the error.
          Regards,
          Jay F.
          Product Manager
          _____________________________________
          Have a suggestion to improve our products?
          Click Support --> Request a Feature in eSignal 11

          Comment

          Working...
          X