Announcement

Collapse
No announcement yet.

Help with Gap Up/Down Script

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

  • Help with Gap Up/Down Script

    Greetings,

    I've hacked together a gap up/down EFS and it's working great on stocks. One problem though. I need the futures (YM, ES) to calculate on the same time 1600 close and 930am open. I've been sitting here for a few hours trying to figure out how to do that. I guess I don't have the expertise. Could someone edit this code so it will correctly calculate the futures gaps? Is that a tall order? Help appreicated. Feel free to DL and use the script all night long. Heres a screen shot and below the code will follow.



    PHP Code:

    function preMain() {
            
    setPriceStudy(true);
            
    setStudyTitle("Gap Zone");
            
    setCursorLabelName("PD-O"0); // Today Open
            
    setCursorLabelName("TD-O"1); // Prev Open
        
            
    setDefaultBarStyle(PS_SOLID0); 
            
    setDefaultBarStyle(PS_SOLID1); 
        
            
    setDefaultBarFgColor(Color.blue0);        
            
    setDefaultBarFgColor(Color.blue1);    
        
            
    setDefaultBarThickness(20); 
            
    setDefaultBarThickness(41); 
        
            
    setPlotType(PLOTTYPE_FLATLINES0); 
            
    setPlotType(PLOTTYPE_FLATLINES1);    
        
    }

    var 
    bInit false;
    var 
    xOpen null;
    var 
    xHigh  null;
    var 
    xLow   null;
    var 
    xClose null

    function 
    main() {
        
        if(
    isMonthly() || isWeekly() || isDaily())
        return;
        
        if(
    bInit == false){
            
    xOpen  open(inv("D"));
            
    xClose close(inv("D")); 
            
    bInit true;
        }
        
        
        var 
    vOpen  getSeries(xOpen);
        var 
    vClose xClose.getValue(-1); 
        if(
    vOpen == null || vClose == null)
        return;
        
        
    gap=(vOpen-vClose);
        
    gap=rnd(gap,2);
        
        if (
    gap 0drawTextPixel(25020"|  GAP UP: +"+gap+"  |"Color.RGB(255,255,255), Color.RGB(0,0,255), Text.ONTOP"Arial"20"Gap");
        if (
    gap 0drawTextPixel(25020"|  GAP DOWN: "+gap+"  |"Color.RGB(255,255,255), Color.RGB(255,0,0), Text.ONTOP"Arial"20"Gap");

    drawTextAbsolute (-5vOpen"*Gap Boundary*"Color.blackColor.whiteText.ONTOP Text.CENTER"Courier"8"TodayOpen" );
    drawTextAbsolute (-5vClose"*Gap Boundary*"Color.blackColor.whiteText.ONTOP Text.CENTER"Courier"8"PrevClse" );

        
        return new Array (
    vOpen,vClose);
    }


    //==rnd will round to N digits (thanks TRO for rounding code)

    function rnd(valueN) {

        var 
    n;

        var 
    mult=1;

        for(
    n=0;n<N;n++) mult*=10;

        
    value*=mult;

        return 
    Math.roundvalue,N)/mult;



  • #2
    Hello Geoff,

    To create the equivalent daily bar for YM and ES you first need to add a user-defined interval to your time template of 390 and set the start and end time for this interval to 930 and 1600. 390 is the number of minutes between those times. This 390 interval creates one bar per day, which will allow you to mimic the logic that your formula currently processes for equity symbols. In your xOpen and xClose series use inv(390) in place of inv("D"). You could also take this one small step further and search the symbol for a space (or something along these lines) within your bInit block so that you can continue to use inv("D") for equities and inv(390) for futures.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Great. What would I do without this place. I will give it a go and post the modified code within 24 to 396 hours.

      Comment


      • #4
        Hi! I sorta have it working. I made the changes but it only works properly if my chart Time Template is set to 9:30-16:00. Is there a way I can 'force' this time template via an EFS? Or can I get the current time template and if its not correct output a message to the user to switch it. Thanks!

        Comment


        • #5
          Hello Geoff,

          At this time EFS does not have the ability to change or view the settings of the current time template that is applied to the chart.
          Jason K.
          Project Manager
          eSignal - an Interactive Data company

          EFS KnowledgeBase
          JavaScript for EFS Video Series
          EFS Beginner Tutorial Series
          EFS Glossary
          Custom EFS Development Policy

          New User Orientation

          Comment

          Working...
          X