Announcement

Collapse
No announcement yet.

Ama

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

  • Ama

    I want to create this moving average

    Value1 =
    +0.4360409450*Close[0]
    +0.3658689069*Close[1]
    +0.2460452079*Close[2]
    +0.1104506886*Close[3]
    -0.0054034585*Close[4]
    -0.0760367731*Close[5]
    -0.0933058722*Close[6]
    -0.0670110374*Close[7]
    -0.0190795053*Close[8]
    +0.0259609206*Close[9]
    +0.0502044896*Close[10]
    +0.0477818607*Close[11]
    +0.0249252327*Close[12]
    -0.0047706151*Close[13]
    -0.0272432537*Close[14]
    -0.0338917071*Close[15]
    -0.0244141482*Close[16]
    -0.0055774838*Close[17]
    +0.0128149838*Close[18]
    +0.0226522218*Close[19]
    +0.0208778257*Close[20]
    +0.0100299086*Close[21]
    -0.0036771622*Close[22]
    -0.0136744850*Close[23]
    -0.0160483392*Close[24]
    -0.0108597376*Close[25]
    -0.0016060704*Close[26]
    +0.0069480557*Close[27]
    +0.0110573605*Close[28]
    +0.0095711419*Close[29]
    +0.0040444064*Close[30]
    -0.0023824623*Close[31]
    -0.0067093714*Close[32]
    -0.0072003400*Close[33]
    -0.0047717710*Close[34]
    +0.0005541115*Close[35]
    +0.0007860160*Close[36]
    +0.0130129076*Close[37]
    +0.0040364019*Close[38];

    Close[0] is the close today
    Close[30] is the close 30 days ago

    Thanks

  • #2
    pbereau
    Just before your equation add the lines shown below which will create the necessary array and perform a null check.
    Then all you need to do is return Value1 to the chart
    Alex

    PHP Code:
    var Close getValue("Close",0,-39);
    if(
    Close[38]==null) return; 

    Comment


    • #3
      Hi Alex i've write this
      It doesn't work...where are my errors ?
      Also I want the mov average to be on my price bars


      {function preMain()
      setPriceStudy(true);
      setStudyTitle("FAST");
      setCursorLabelName("FAST", 0);
      setDefaultBarFgColor(Color.black, 0);
      }
      {function main
      var Close = getValue("Close",0,-39);
      if(Close[38]==null)
      return;
      var Value1 = +0.4360409450*Close[0] +0.3658689069*Close[1] +0.2460452079*Close[2] +0.1104506886*Close[3] -0.0054034585*Close[4] -0.0760367731*Close[5] -0.0933058722*Close[6] -0.0670110374*Close[7] -0.0190795053*Close[8] +0.0259609206*Close[9] +0.0502044896*Close[10] +0.0477818607*Close[11] +0.0249252327*Close[12] -0.0047706151*Close[13] -0.0272432537*Close[14] -0.0338917071*Close[15] -0.0244141482*Close[16] -0.0055774838*Close[17] +0.0128149838*Close[18] +0.0226522218*Close[19] +0.0208778257*Close[20] +0.0100299086*Close[21] -0.0036771622*Close[22] -0.0136744850*Close[23] -0.0160483392*Close[24] -0.0108597376*Close[25] -0.0016060704*Close[26] +0.0069480557*Close[27] +0.0110573605*Close[28] +0.0095711419*Close[29] +0.0040444064*Close[30] -0.0023824623*Close[31] -0.0067093714*Close[32] -0.0072003400*Close[33] -0.0047717710*Close[34] +0.0005541115*Close[35] +0.0007860160*Close[36] +0.0130129076*Close[37] +0.0040364019*Close[38]);
      return Value1
      }

      Comment


      • #4
        pbereau
        You have the open bracket ie { in the wrong location in both function preMain and function main. The open bracket should be after the function and the parenthesis ie function preMain(){ and not before.
        Also in function main you omitted to include the parenthesis () ie function main()
        Alex

        Comment

        Working...
        X