Announcement

Collapse
No announcement yet.

new to arrays question

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

  • new to arrays question

    Howdy Folks,
    Really new to arrays and I'm sure there is a fairly simple solution... but i'm obviously missing the train.
    I'm trading one hour charts and getting my seconds, minutes from a 5 second chart (thanks to Steve and Alexis) through a global variable. My question is as follows... I keep track of the days high and low and at midnight would like them to become yesterdays high and low, the reason for this is to be able to use this data in both real and playback mode. I could be wrong but it seems that just popping these two pieces of info into a 2x2 array should work. Anyone seen an EFS that could demonstrate to me how this might be accomplished... like I say, i'm new to arrays.
    Thanks.

  • #2
    Hi Chris,

    I have become partial to arrays of objects. Here is a link to my fileshare which has a folder on arrays here.

    Here is a copy of an efs I put together which I thought would be of some help to you:
    PHP Code:
    var index 0;
    var 
    bsP = new Array();
    var 
    text1 "Press this button to output the last 10 points of your array"

    function 
    preMain(){
        
    setPriceStudy(true);
        
    setShowTitleParameters(false);
        
    setStudyTitle("Array of XYZ");
        
    setShowCursorLabel(false);
        }

    function 
    main(    ){
        if (
    getBarState() == BARSTATE_ALLBARS) {//true once during initial load and subsequent reload

        
    }
        
        if (
    getBarState() == BARSTATE_NEWBAR) {
            var 
    tmp = new Your_Obj (high(-1), low(-1),close(-1));//last bar closing data
            
    bsP.push(tmp);
        }
        
    OutputButton();
    }

    function 
    OutputButton(){
        var 
    flagS Text.RELATIVETOLEFT Text.RELATIVETOBOTTOM|Text.FRAME;
        
    drawTextAbsolute(1515text1+"@URL=EFS:Output_Data",  Color.rednullflagS"Comic Sans MS"13,"747");
    }

    function 
    Output_Data(){
        var 
    len bsP.length;
        var 
    begin 0;
        if (
    len-begin>10)begin len-10;
        for (var 
    i=begin;i<len-1;i++){
            
    debugPrintln("34: for ArrayObject["+i+"]==>>\tX = "+bsP[i].X.toFixed(2)+"\tY = "+bsP[i].Y.toFixed(2)+"\tZ = "+bsP[i].Z.toFixed(2));
        }
        
    OutputButton();
    }

    function 
    Your_Obj (x,y,z){
        
    this.x;
        
    this.y;
        
    this.z;

    I hope this helps to get you back on the tracks ;>).

    Comment


    • #3
      Thanks Steve... as usual, above and beyond the call !!! I appreciate it and in fact i believe i'm now on track with arrays !

      Thanks,
      Chris

      Comment

      Working...
      X