Announcement

Collapse
No announcement yet.

Range of intraday session

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

  • Range of intraday session

    hi, I have an indicator that I have coded that records the range for a specific time of day. The indicator itself works fine, however since I have started using this I have begun experiencing issues with my Esignal connection. When I open a page some charts get stuck on requesting data. The specific charts that get stuck change from time to time, so I don't believe it is product specific. I have spoken with Esignal support a number of times and their solution is do a complete reinstall and rebuild all my pages and charts from scratch. However with the amount of charts and pages I have setup this is something I am extremely loathe to do. I'm far from an Esignal code expert, so I was wondering if this problem was somehow related to the way I have coded this indicator? ( it is so inefficiently coded it uses huge amounts of resources, unneccesarily, to load up. This indicator runs on about 40 charts on one page with 3 session times on each chart.

    I just want to try and rule out absolutely everything else before having to do a full reinstall. Any help or suggestions would be greatly appreciated!! Below is the code in its entirety.

    Code:
    var rng = null;
    var CMEEUR = null;
    var val = null;
    var ddeCMEEUR = null;
    var X=1;
    function preMain() {
        setPriceStudy(false);
        setStudyTitle("CME Euro Range");
        setCursorLabelName("CME Euro Range");
        setDefaultBarStyle(PS_SOLID, 0);
        setDefaultBarFgColor(Color.blue, 0);
        setDefaultBarThickness(5, 0);
        setPlotType(PLOTTYPE_HISTOGRAM, 0);
    }
    
    function main()
    {
    
    if (getHour(0) >= 3 && getHour(0) < 7 && day(0) == day(-1))
    {
    if(getBarState()==BARSTATE_NEWBAR){
    //volus+=volume(-1);
    X += 1;
    if(X>1){
    rng = efsInternal("HHH");
    val = highest(X, rng);
    CMEEUR = val.getValue(0)
    
        if (ddeCMEEUR == null){
        var sName = "CMEEUR" + getSymbol() + getInterval();
             sName = sName.replace(/\$/g, ""); // remove $ from string
            sName = sName.replace(/\#/g, ""); // remove # from string
            sName = sName.replace(/\-/g, "");
            sName = sName.replace(/\(/g, "");
            sName = sName.replace(/\!/g, "");        
            sName = sName.replace(/\=/g, "");
            sName = sName.replace(/\:/g, "");
            sName = sName.replace(/\)/g, "");
            sName = sName.replace(/\ /g, "_") // replace space with underscore
            debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
            ddeCMEEUR = new DDEOutput(sName);
            }
       }
    
    }
    ddeCMEEUR.set(CMEEUR);
    }else{
    if (getHour(0) >= 7 || getHour(0) <= 2 || day(0) != day(-1)){
    X=1;
    CMEEUR = 0;
    }
    }
    return CMEEUR;
    }
    var Highest = null;
    var W =1;
    function HHH() { 
        //if(!isIntraday()) return; //otherwise "gt" won't equal the start and end times 
        if (getHour(0) >= 3 && getHour(0) < 7 && day(0) == day(-1))
        {
        if(getBarState()==BARSTATE_NEWBAR){
        W += 1;
        }
        if(W>1){
        var HIGH = highest(W-1, high());
        var LOW = lowest(W-1, low());
        //if (getHour(0)==11 && getMinute(0)==55)
        //{
        Highest = HIGH - LOW//Math.abs(highest(48, high(),-1) - lowest(48, low(),-1));
        //}
        }
       }else{Highest=0;W=1;}
        return Highest;
     }
Working...
X