Convert call dll from Metastock to MetaTrader4

Discussion in 'MetaTrader' started by Fahad04, Aug 14, 2016.

  1. Fahad04

    Fahad04 New Member

    Joined:
    Jun 1, 2016
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Please help me to call dll file using MT4

    File name: FileName.dll
    Function name is : CheckFunction

    Metastock formula to call dll function is :
    Buy
    ExtFml( "FileName.CheckFunction") = 1

    Sell
    ExtFml( "FileName.CheckFunction") = 0
     
  2. mastermind007

    mastermind007 Well-Known Member

    Joined:
    Dec 17, 2011
    Messages:
    2,336
    Likes Received:
    2,293
    Trophy Points:
    113
    General steps to call any function from any dll are

    1) Load Library
    2) obtain function pointer of the desired function from the export table of the loaded library
    3) call the function pointer
    4) Repeat steps 2 and 3 as many times as necessary
    5) Unload library

    But, to successfully complete each of the step requires some programming skill.

    There are lot of complications involved. Some C DLL (notably microsoft) use parameter loading in opposite order (sometimes called PASCAL convention) as opposed to default C convention.

    Some compilers expect strings memory allocation to be on stack whereas others expect it to be in heap memory.
     
  3. Fahad04

    Fahad04 New Member

    Joined:
    Jun 1, 2016
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Hi Master Mind,

    thank for your help


    is this correct?

    this is my try:

    #import "FileName.dll";
    double CheckFunction();
    #import

    and in the void OnTick() I put this
    Print(CheckFunction());

    but no value showed up!!!
     
Loading...

Share This Page