Announcement

Collapse
No announcement yet.

Efs Questions For Advanced Users Only!!!!!!

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Efs Questions For Advanced Users Only!!!!!!

    I have three questions.
    1. In some code that I'm porting over from TradeStation, the code relied on the fact that a chart can be loaded with a certain number of days. For example, 100 days back for a 5 minute chart. However, eSignal does not load sufficient data when you open a chart and I cannot find a way to make it do so. If my efs code requires n days of data, how can I do this in the efs. (For example, can I reference data before the first bar to cause more data to be loaded?)

    2. How can I convert open/high/low/close data from floating point to integer. For example, the e-mini is traded in 1/4's and let's say the open is 985.25. How do I convert it from 985.25 to 98525 - which is how you display it? Specifically, how do I determine the scaling multiplier, which may be different for different symbols? This is important because I have 10,000 lines of dll code that uses integer arithmetic for speed reasons and I can't re-write all this code.

    3. The documentation I have mentions that strings can be passed between an efs and a dll. It does not describe how you actually do this but someone (Dion, I think) on you support team told me strings are passed by reference, specifically as far pointers. I have tried a variety of ways of passing a string from the dll and into an efs varibale but have been unsuccessful. Can you please show me an example piece of code - both the C code for the dll and the efs code - that allows a string to be returned from the dll and into an efs variable.

    The following looks like it should work but it does not. It does return the expected string length which means "Hello\n" was successfully copied into far char* str. But the efs does not see the modified str variable.

    ==== EFS CODE
    dll = new DLL("c:/eSignal.dll");
    function preMain() {
    dll.addFunction("getStr",DLL.FLOAT,DLL.STDCALL,"ge tStr",DLL.STRING);
    }
    function main() {
    str = "1234567890"; // malloc 10 bytes of string space
    rc = dll.call("getStr",str);
    debugPrintln(rc + " " + str);
    }
    ==== DLL CODE
    float __stdcall getStr(far char *str) {
    strcpy(str,"Hello\n");
    return((float)strlen(str));
    }



    -----------------------------------------------------------------

    Thank you all for your help and yes .................when we get these last few issues addressed you will have the ablility to run the T-3 Fibs ProTrader automated fibonacci areas on E-signal ... www.nss-t3.com thanks John Novak

  • #2
    John:

    In terms of preloading data into a chart... that is the function of the eSignal Time Templates. Using the Time Template feature you can pre-load a user-specified number of bars or days worth of data into any Advanced Chart.

    Regarding the DLL's... I have done lots of work with DLLs but I use Delphi raather than C. The two languages are similar enough, however, so here is an example Delphi DLL that demonstrates how to pass strings. If it doesn't help, I'm sure one of the eSignal folks will chime in.

    PHP Code:
    library DelphiExampleDll;

    uses
      SysUtils
    ,
      
    Classes,
      
    Math;


    //Custom type that facilitates the passing of arrays from EFS to Delphi. Follow
    //the same logic to pass Arrays of Integer or String. Remember than when passing
    //Strings you will use PChar and NOT String.
    type
        TTest 
    = Array[0..1023of Double;

    {
    $R *.RES}



    //== This is the function that will be called ultimately by the
    //== EFS script. We pass it an Integer, a String, an Array of Double
    //== and a Double. The function returns a Double value to the
    //== calling EFS routine. Note the StdCall at the end of the function
    //== declaration... don't forget this!

    function MyUselessFunctionMyIntIntegerMyStringPCharMyDoubleArrayTTestMyDoubleDouble ) : DoubleStdCall;
    var
        
    x:          Integer;
    begin

        
    //This stub DLL does not do anything other than show how the various variables
        //should be passed to a Delphi DLL

        //Passing Integers and Doubles is straightforward and requires no discussion.

        //Notice that MyString is declared as a PChar and not a String. Once we have it
        //in Delphi, we can work with it as a 'regular' string so no problems here.

        //Passing arrays is where it gets tricky. Unfortunately, Array of Double  or
        //Array of Int will not work. Best best is to create a Type definition that
        //meets your requirements. In this example we have declared a Type called
        //TTest as an Array of Double with 1024 elements. When passing the array
        //from the EFS routine, you MUST pad it to exactly 1024 elements. So, even if you
        //are really only passing 200 elements in one particular case, make sure you
        //pad the array in EFS prior to calling the DLL function so that it is the
        //correct length.


        //simply return the passed integer multiplied by the passed Double
        
    Result := MyInt MyDouble;

    end;



    //Finally, you need to create an Exports clause and include the function
    //that you are exporting. DLLs created in this fashion can be used by
    //any Windows program that supports DLLs.

    exports
        MyUselessFunction
    ;

    begin
    end
    .


    //Now, to call this DLL from within an EFS script you would do the following:

    //First, compile the DLL and save it into the eSignal Program Directory
    //( e.g., c:\Program Files\eSignal )

    //In the actual EFS script, you would use code similar to the following

    //var myDLL = new DLL("DelphiExampleDLL.DLL");

    //function preMain() {
    //
    //myDLL.addFunction("Bozo", DLL.DOUBLE, DLL.STDCALL, "MyUselessFunction", DLL.INT, DLL.STRING, DLL.DOUBLEARRAY, DLL.DOUBLE );
    //
    //}

    //function Main() {
    //
    //var myArray = new Array(1024);  // declare the array - size it correctly!!
    //
    //  if ( getBarState()==BARSTATE_NEWBAR ) {
    //      for (x=0; x<1024; x++ ) {   //now we simply fill our array with values
    //          myArray[x] = (x+1)/3;
    //      }
    //      var zz = myDLL.call( "Bozo", 10, "Hello", myArray, 103.234 );
    //  }
    //
    //}


    //zz will now contain the Double value returned by our simple DLL. 
    Chris

    Comment


    • #3
      Ckryza _ thanks!

      Chris,

      going to get to work on this ... will let you know how it turns out... having little to no experience in Esignal..... LOTS of things that you must learn on the fly that are quite different from a tradestation environment.

      This days back thing is a big one for us and the string passing just gets frustrating when it doesn't do what you think.

      Will have feedback after few hours of work here.

      Talk to you soon.

      John

      Comment

      Working...
      X