Announcement

Collapse
No announcement yet.

Adding Bands to indicators

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

  • Adding Bands to indicators

    I am trying to add bands at +30 and -30 to and indicator that has a historgram. I have copied the .els language gelow this request to show the reference points in the study.

    Please note to anyone who is gracious enough to help me with this that this is a password protected .els part of the Kwikpop add-on to e-signal. The developer allows the users to add graphics...like bands...but unfortuately anyone suggesting a solution wont be able to test the solution since a subscription password is required to run the Kwikpop add-on. Please understand that.

    I read the documentation on the website for constructing bands and used:

    addBand(30, PS_Solid,1, Color.black);
    addBand(-30,PS_Solid,1, Color.black);

    to try to get bands on the indicator at +30 and -30 since the oscillator is centered on the zero line.

    I am getting a script error. It aparently does not know what to reference. The 30 line would reference the TSKPFAST1_1 part of the oscillator and the -30 would reference the TSKPFAST1_2 oscillator. I dont know properly how to used the bands to reference the correct part of the indicator. I tried just putting the language at the end of the script shown below...but that isnt working.

    Also...if is possible to use a dotted line instead of a solid line that would be an extra bonus.

    Any help would be appreciated.

    Thanks so much....The .els language follows below...

    / load our DLL in global space.
    var mydll = new DLL("C:\\Program Files\\Kwik POP for eSignal\\kpesignal.dll");

    mydll.addFunction("E_CREATESTATE", DLL.INT, DLL.STDCALL, "E_CREATESTATE", DLL.STRING, DLL.INT);
    mydll.addFunction("E_CHECKSTATE", DLL.INT, DLL.STDCALL, "E_CHECKSTATE", DLL.INT);
    mydll.addFunction("E_BARVALUES", DLL.INT, DLL.STDCALL, "E_BARVALUES", DLL.INT, DLL.INT, DLL.INT, DLL.INT, DLL.DOUBLE, DLL.DOUBLE, DLL.DOUBLE, DLL.DOUBLE, DLL.DOUBLE);
    mydll.addFunction("E_GETRETURN",DLL.DOUBLE,DLL.STD CALL, "E_GETRETURN",DLL.INT,DLL.INT);

    mydll.addFunction("E_TSKPFAST1", DLL.DOUBLE, DLL.STDCALL, "E_TSKPFAST1", DLL.INT);

    function preMain()
    {

    setPriceStudy(false);
    setStudyTitle("TSKPFAST1");

    setCursorLabelName("TSKPFAST1_1",0);
    setDefaultBarFgColor(Color.blue,0);
    setPlotType(PLOTTYPE_HISTOGRAM , 0 );

    setCursorLabelName("TSKPFAST1_2",1);
    setDefaultBarFgColor(Color.red,1);
    setPlotType(PLOTTYPE_HISTOGRAM , 1 );

    setCursorLabelName("TSKPFAST1_3",2);
    setDefaultBarFgColor(Color.yellow,2);

    setCursorLabelName("TSKPFAST1_4",3);
    setDefaultBarFgColor(Color.cyan,3);

    }

    var stateID = 0;
    var cum1 = 0;

    function longdate()
    {
    var ldate = getYear() * 10000;
    ldate += getMonth() * 100;
    ldate += getDay();

    return ldate;
    }

    function longtime()
    {
    var ltime = getHour() * 10000;
    ltime += getMinute() * 100;
    ltime += getSecond();

    return ltime;
    }

    function main()
    {
    //first thing we're going to plot is TSKPa900

    var nBarState = getBarState();
    if ( nBarState == BARSTATE_ALLBARS)
    {
    cum1 = 0;
    stateID = 0;
    // make it create a new state when it starts up.
    }
    else if( nBarState == BARSTATE_NEWBAR)
    {
    cum1++;
    }

    var r = new Array();
    r[0] = 0.0;
    r[1] = 0.0;
    r[2] = 0.0;
    r[3] = 0.0;



    if( stateID != 0 )
    {
    var check = mydll.call("E_CHECKSTATE", stateID);

    if( check == 0 )
    {
    // We have to recalculate from the first bar.
    reloadEFS();
    stateID = 0;
    }
    }


    if( stateID == 0 )
    {
    stateID = mydll.call("E_CREATESTATE",getUserName(),1); // the 1 tells it to use garbage collection.
    }

    if( stateID )
    {

    // we actually have gotten this far, we can go ahead and try to do something.
    // mydll.addFunction("E_BARVALUES", DLL.INT, DLL.CDECL, "E_BARVALUES", DLL.INT, DLL.INT, DLL.INT, DLL.INT, DLL.DOUBLE, DLL.DOUBLE, DLL.DOUBLE, DLL.DOUBLE, DLL.DOUBLE);

    var bv = mydll.call("E_BARVALUES",stateID,cum1, longdate(), longtime(), open(), high(), low(), close(), volume());
    if( bv != 0 )
    {

    // they actually seem to have a license.
    // this is where we calculate an actual indicator value.

    mydll.call("E_TSKPFAST1", stateID);

    // return both values
    r[0] = mydll.call("E_GETRETURN",stateID,0);
    r[1] = mydll.call("E_GETRETURN",stateID,1);
    r[2] = mydll.call("E_GETRETURN",stateID,2);
    r[3] = mydll.call("E_GETRETURN",stateID,3);

    setBarThickness(2,0);
    setBarThickness(2,1);
    }

    }

    return (r);
    }

    Last edited by lorend; 11-26-2005, 11:37 AM.

  • #2
    lorend,

    If you attach the script (EFS) file in the thread it would make it much easier for one of us to look at the code and Inform you on how to correct it.

    To make the lines appear dotted use PS_DOT in place of PS_SOLID.
    Last edited by FibbGann; 11-26-2005, 10:50 AM.
    Excellent book on JavaScript for beginners

    Comment


    • #3
      lorend
      You are missing the TagName parameter in your addBand() function.
      See this article in the EFS KnowledgeBase for the required syntax
      Alex

      Comment

      Working...
      X