Code Monkey home page Code Monkey logo

pythondll's Introduction

PythonDll

A DLL wrapper for Python 3.6 programmed in C++ (Visual Studio) - intended for use in MT5 (MQL5)

The intended application of this project is to create a 64bit linker to python for use in metatrader 5 (mql5).

Example import in mql5:

#import "[Path to PythonDll.dll"
   long CallPython(double &a[][11], int array_rows, int array_cols, string &FileName, string &FuncName, int &args[]);
#import

Example call in mql5:

void CallPython()
  {
   Print("Writing data to file...");
   double AllInputs[][11];    // 2D matrix of data to be passed to python (the Dll allows for up to 20 fields but you can use fewer)
   EnterDataIntoMatrix(AllInputs,NumRows); // Add data to the matrix using another function (EnterDataIntoMatrix) 
   int args[] = {1,1}; //Add any additional arguments that will be passed to python
   string FileString = "PythonCode"; //Name of the python file E.g. PythonCode.py
   string FuncString = "WriteData"; //Name ofthe function in the python file. Example here is for: def WriteData(a, args):
   Print("Result = " ,CallPython(AllInputs,NumRows,NumCols,FileString,FuncString,args)); //Call the python function and retrieve a long result (NumCols=11 in this example)
   
   return(INIT_SUCCEEDED);
  }

Example python function:

def WriteData(matrix, args):
    DataFileName = 'AllData.csv'
    file = open(DataFileName, 'w')
    writer = csv.writer(file,lineterminator = '\n')
    for row in matrix:
        writer.writerow(row)
    
    file.close()
    return 1;

pythondll's People

Contributors

sdswart avatar

Watchers

James Cloos avatar ZQ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.