Kick off Trade Via Batch/VBS Script
Results 1 to 7 of 37

Thread: Kick off Trade Via Batch/VBS Script

  1. #1
    Is it feasible to start a trade via a vbs or heap script? I've got an appliion that doesn't port with MetaTrader but I'd love to automate a trading system based upon it has signs.

    FYI: This is not a web-based system that I have access to in anyhow (i.e. can't build a dll or component app to communie with this).

  2. #2
    Should be possible, if the two progr (MT4 external sys) are loed on the exact same pc.

    Your external sys should place a document from the MT4/experts/files folder.

    You create an EA in MT4 which is scanning for this document. Read the document, if it finds it and process the orders. The EA scans every moment or so for another file and deletes the document once done.

    gl,

  3. #3
    That sounds like a plan.

    I guess it would be just easier to have my external platform produce a 0 byte evaluation file called trade.txt and when the EA sees that document it would commence a trade.

    Are there any articles or documentation that show how to assign a variable in an external file such as that?

  4. #4
    I am taking a look at the document works that are kernel32. Is this a valid statement:

    string ReadFile (string path)
    {
    int handle=_lopen (path,OF_READ);
    if(handlelt;0)

    factor = 0 // 0 to do not commerce

    else

    factor = 1 // 1 for commerce

  5. #5
    So, I have completed a script which will do what I am looking to do for changes. So that this script will operate, how do I add the element of time? Also, I do not want it to trade when there is currently a trade in progress.

    Inserted Code #include lt;stdlib.mqhgt; #include lt;WinUser32.mqhgt; int filetrade; // lopen #define OF_READ 0 #define OF_WRITE 1 #define OF_READWRITE 2 #define OF_SHARE_COMPAT 3 #define OF_SHARE_DENY_NONE 4 #define OF_SHARE_DENY_READ 5 #define OF_SHARE_DENY_WRITE 6 #define OF_SHARE_EXCLUSIVE 7 #import kernel32.dll int _lopen (string path, int of); int _lcreat (string path, int attrib); int _llseek (int handle, int offset, int source); int _lread (int handle, string buffer, int bytes); int _lwrite (int handle, string buffer, int bytes); int _lclose (int handle); #import // ------------------------------------------------------------------ //| script program start operate | // ------------------------------------------------------------------ string start(string path) //-- int handle=_lopen (C:trade.txt,OF_READ); if(handlegt;0) if(MessageBox(Do you really want to BUY 1.00 Symbol() at ASK price? , Script,MB_YESNO else Print(Error opening file ,path); return (); int effect=_llseek (handle,0,0); result=_lclose (handle); return(0);

  6. #6
    I suspect that if I run this as an EA that it would continually check for the document (as long as there are not open trades). Is this a correct assumption?

    Also, for some reason, the script is not closing the document. This is my updated script:

    Inserted Code #include lt;stdlib.mqhgt; #include lt;WinUser32.mqhgt; extern string filetrade=C:\trade.txt; // lopen #define OF_READ 0 #import kernel32.dll int _lopen (string path, int of); int _llseek (int handle, int offset, int source); int _lclose (int handle); #import // ------------------------------------------------------------------ //| script program begin operate | // ------------------------------------------------------------------ string start(string path) //-- int handle=_lopen (filetrade,OF_READ); int result=_llseek (manage,0,0); int total=OrdersTotal(); should(handlegt;0) if(totallt;1) MB_ICONQUESTION)! =IDYES) return(1); int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,spe cialist comment,255,0,CLR_NONE); should(ticketlt;1) int error=GetLastError(); Print(Error = ,ErrorDescription(error)); return; OrderPrint(); outcome=_lclose (handle); else Print(Error opening file ,path); outcome=_lclose (manage); return (); result=_lclose (manage); return(0);

  7. #7
    I figured out how to repair the script not closing the file, though I do understand the logic. In hindsight I guess that this does make sense as long as the file could be opened, the worth of handle would not be 0.

    I needed to put the closing statement directly after the open statement:

    Inserted Code int complete=OrdersTotal(); int handle=_lopen (filetrade,OF_READ); int fclose=_lclose (manage); when(handlegt;0) ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.