This is the EFS1 code for the DLL.
I took the guts of the DLL and put into an efslib. Here is that code.
And here is the new indicator in EFS2.
I have no idea if this is the correct/best way to convert a DLL to EFS2. Any suggestions or comments would be appreciated.
There are also DLL indicators that return an array of values that I will have to worry about.
Thanks
PHP Code:
// 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_TSKPA900", DLL.DOUBLE, DLL.STDCALL, "E_TSKPA900", DLL.INT);
var DFLAG = 0;
function preMain()
{
setPriceStudy(true);
setStudyTitle("TSKPa900");
setCursorLabelName("TSKPa900",0);
setDefaultBarFgColor(Color.lime,0);
}
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 tskpa900 = 0;
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++;
}
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.
// of the function in the DLL it still crashes.
tskpa900 = mydll.call("E_TSKPA900", stateID);
}
}
return (tskpa900);
}
PHP Code:
// Kwik Pop Function Library
// load our DLL in global space.
var KPdll = new DLL("C:\\Program Files\\Kwik POP for eSignal\\kpesignal.dll");
//common to all KP indicators
KPdll.addFunction("E_CREATESTATE", DLL.INT, DLL.STDCALL, "E_CREATESTATE", DLL.STRING, DLL.INT);
KPdll.addFunction("E_CHECKSTATE", DLL.INT, DLL.STDCALL, "E_CHECKSTATE", DLL.INT);
KPdll.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);
// specific KP indicators
KPdll.addFunction("E_TSKPA900", DLL.DOUBLE, DLL.STDCALL, "E_TSKPA900", DLL.INT);
function initLib()
{
}
var stateID = 0;
var cum1 = 0;
var vSymbol = null;
function longdate()
{
var ldate = getYear(0,sym(vSymbol)) * 10000;
ldate += getMonth(0,sym(vSymbol)) * 100;
ldate += getDay(0,sym(vSymbol));
return ldate;
}
function longtime()
{
var ltime = getHour(0,sym(vSymbol)) * 10000;
ltime += getMinute(0,sym(vSymbol)) * 100;
ltime += getSecond(0,sym(vSymbol));
return ltime;
}
function A900(symbol, interval)
{
var tskpa900 = 0;
var nBarState = getBarState();
if(symbol == null) symbol = getSymbol();
if(interval == null) interval = getInterval();
vSymbol = symbol + "," + interval;
if ( nBarState == BARSTATE_ALLBARS)
{
cum1 = 0;
stateID = 0;
// make it create a new state when it starts up.
}
else if( nBarState == BARSTATE_NEWBAR)
{
cum1++;
}
if( stateID != 0 )
{
var check = KPdll.call("E_CHECKSTATE", stateID);
if( check == 0 )
{
// We have to recalculate from the first bar.
reloadEFS();
stateID = 0;
}
}
if( stateID == 0 )
{
stateID = KPdll.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 = KPdll.call("E_BARVALUES",stateID,cum1, longdate(), longtime(), open(0,sym(vSymbol)), high(0,sym(vSymbol)), low(0,sym(vSymbol)), close(0,sym(vSymbol)), volume(0,sym(vSymbol)));
if( bv != 0 )
{
// this is where we calculate an actual indicator value.
tskpa900 = KPdll.call("E_TSKPA900", stateID);
}
}
return (tskpa900);
}
PHP Code:
// Plot ESKPa900 on the price chart
function preMain()
{
setPriceStudy(true);
setStudyTitle("ESKPa900A");
setCursorLabelName("ESKPa900",0);
setDefaultBarFgColor(Color.lime,0);
//Formula Parameters
fp1 = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fp1) {
setDefault("");
}
fp2 = new FunctionParameter("Interval", FunctionParameter.NUMBER);
with(fp2) {
setDefault("");
}
}
// global variables
var KPLib = addLibrary("KPFunctions.efsLib")
var bInit = false; //initialization flag
var xa900 = null; //a900
function main(Symbol, Interval)
{
// one time initialization
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
bInit = true;
}
xa900 = KPLib.A900(Symbol, Interval);
return xa900;
}
There are also DLL indicators that return an array of values that I will have to worry about.
Thanks
Comment