Announcement

Collapse
No announcement yet.

Negative Offset-Moving Average dont work

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

  • Negative Offset-Moving Average dont work

    Hi,

    I have problem with negative offset-moving average. After I insert the indicator, the negative offset-ma work only for historical bars not for the new bars.

    PHP Code:
    function preMain()
    {
        
    setPriceStudy(true);
        
    setStudyTitle("offset - test");
        
    setShowCursorLabel(true);
        
        
    setPlotType(PLOTTYPE_LINE,0);    
        
    setPlotType(PLOTTYPE_LINE,1);

        
    setDefaultBarFgColor(Color.green,0);
        
    setDefaultBarFgColor(Color.red,1);
        
        
    setDefaultBarThickness(2,0);
        
    setDefaultBarThickness(2,1);

        
    //setComputeOnClose(true);

        
    fp1 = new FunctionParameter("MA1"FunctionParameter.NUMBER);
        
    fp1.setDefault(89);
        
        
    fp2 = new FunctionParameter("MA2"FunctionParameter.STRING);
        
    fp2.setDefault(34);



    }


    var 
    bInit false;
    function 
    main(MA1MA2)
    {

        if (
    bInit == false)
        {
            
            
    myMA1 offsetSeries(sma(MA1close()), 2);
            
    myMA2 offsetSeries(ema(MA2close()), -2);
            
            
    bInit true;
        }


        return new Array(
    myMA1.getValue(0), myMA2.getValue(0));

    If I insert the indicator Moving Average from Basic Studies with Offset -2 it show me the correctly values realtime, but I cant use the code, it dont work, what do I wrong?

    I need the -2 value for an crossover-alert.
    Attached Files
    Last edited by Roman76; 03-07-2006, 03:06 AM.

  • #2
    Re: Negative Offset-Moving Average dont work

    Originally posted by Roman76
    If I insert the indicator Moving Average from Basic Studies with Offset -2 it show me the correctly values realtime, but I cant use the code, it dont work, what do I wrong?
    Hi Roman76,

    Here is a thread with a similar question and answer. It also shows how to troubleshoot the the code using debugPrint.

    Comment


    • #3
      hi stevehare2003,

      thank you for the link!

      Comment


      • #4
        Hi Roman76,

        You are most welcome.

        Comment

        Working...
        X