Announcement

Collapse
No announcement yet.

Daily Price Range

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

  • Daily Price Range

    Hi,

    I am new to e-signal and trying to find my way through all the information.

    I was hoping someone would be able to tell me where I could find or get a Java script of the average daily price movement over 10 days, 20 days etc.. and a moving average cross over script for alerts and back testing.

    Cheers

    W

  • #2
    W,

    I'm pretty new as well but I think something like the following is what you're looking for. Re the moving ave crossover: there's one in the library.

    PHP Code:
    var vCntr=0;

    function 
    preMain(){
        
    setStudyTitle("Average Change");
        
    setPlotType(PLOTTYPE_HISTOGRAM);
        
    setDefaultBarThickness(6);
    }

    function 
    main(vNumberOfDays){
        
        
    //default number of days is 10 change it in the study params
        
    if (vNumberOfDays==null)var vNumberOfDays 10;              
                        
        
        var 
    vAverageChange=0;
        var 
    vChangeSum 0;
        
        if(
    getBarState()==BARSTATE_NEWBAR)vCntr++;
        
        if (
    vCntr>vNumberOfDays){                                      //gotta have enough days
            
    for(0> -1*vNumberOfDays i--){                    //go through the last 10 days
                
    vChangeSum += (close(i)-open(i));                      //add up the changes
            
    }
            
    vAverageChange vChangeSum/vNumberOfDays;              //calc the average
            
    if (vAverageChange>0)setBarFgColor(Color.green);
            if (
    vAverageChange<0)setBarFgColor(Color.red);
            return 
    vAverageChange;          //draw the graph
        
    }


    Cheers,

    Dennis
    Last edited by daugustine; 08-05-2003, 04:39 PM.

    Comment

    Working...
    X