Can your Algo read. Txt files and place orders? , If so process and format please

I think there is no in-Built function in Pi to do that.But instead, U Can use PiBridge to Place order from Text File…U Can use any Programming Language like VBScript or C++ to raed the text file content and place order in Pi using PiBridge.

The Following is the Detailed Process…

Ensure U are Subscribed to PiBridge

Ensure in Pi UserSettings under PiBridge Tab…U have selected Live semiAutomatic options

Copy the File Pibridge.dll from Amibroker Directory to C:\Windows\System32 Folder

Just Coded For MKT order Type Only…U Can modify the code to suit any Order Type


Create a Text File with Name Order.txt

add Trade Details in the below Format

OneLine Per Trade

Trade,Exch,Symbol,TradeSymbol,OrderType,ProductType,ClientId,Qty

Example:-

BUY,NSE,ACC,ACC-EQ,MKT,MIS,AB0123,120

SELL,NSE,AXISBANK,AXISBANK-EQ,MKT,MIS,AB0123,250

after adding required Trades save and close the Order.txt File

Now open a New Text Document and Copy paste the below code and save the file with .vbs extenstion and give any name For Ex:- Bridge.vbs

'Starting Code
On Error Resume Next
Dim objFSO,objFile,bridge,strline,strarr
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set bridge = CreateObject(“pibridge.Bridge”)
Set objFile= objFSO.OpenTextFile(“Order.txt”, 1)
Do Until objFile.AtEndOfStream
strLine = objFile.readline
strarr = split(strline,",")
if ucase(strarr(0)) = “BUY” then
Trade = 1
Exch = ucase(strarr(1))
Symbol = ucase(strarr(2))
TrdSymbol = ucase(strarr(3))
OrdType = ucase(strarr(4))
ProdType = ucase(strarr(5))
ClientId = ucase(strarr(6))
Qty = CInt(strarr(7))
call bridge.PlaceOrder (Exch, TrdSymbol ,Symbol,“TEST”, Trade ,Qty,0,0,0,OrdType , ProdType, ClientId,“DAY”)
elseif ucase(strarr(0)) = “SELL” then
Trade = 2
Exch = ucase(strarr(1))
Symbol = ucase(strarr(2))
TrdSymbol = ucase(strarr(3))
OrdType = ucase(strarr(4))
ProdType = ucase(strarr(5))
ClientId = ucase(strarr(6))
Qty = CInt(strarr(7))
call bridge.PlaceOrder (Exch, TrdSymbol ,Symbol,“TEST”, Trade ,Qty,0,0,0,OrdType , ProdType, ClientId,“DAY”)
else
end if
Loop
objFile.Close
set objFSO = Nothing
Set bridge = Nothing
’End Code

Now double click the file bridge.vbs. It will read all lines in the Order.txt File and Place order in Pi accordingly…You can check your Order Details in Generated Orders alerts window in Pi.

Ensure that Order.txt File and Bridge.vbs file are in same directory/Folder.

Post ur Comment

Great, thanks for putting the details . What if the text signals are generated in one of the MT4 platforms. how do we read them

If U are using MT for Signal Generation…then this method is a workaround to place Order in Pi from MT…I’m not familier with MQL. If is there any option in MQL…when Buy Signal occurs write a text file like that…then it is possible to fire orders to Pi from MT

Thanks for the Update buddy. Yes, I’ve created a script which is writing a text file. how can i proceed further.

Hi rgv…
It is easy to implement…But the requirement is…
When a Buy/sell signal came,You mt Script should create a text file with file name as symbol name in which signal came and write the trade details in the format i mentioned.
Then the vbs can be modified to read the text file and place Order.
The Overall Structure as follows…
Example
Buy signal came in stock AAA and your MT script create a text file with name AAA.txt in Desktop/Orders Folder.and write Trade Details Like BUY,AAA,AAA-EQ,MKT,MIS,AB0123,250
As soon as the the file is created,Vbs will read the file place buy order in Pi and after Placing order will delete the text File.
Sell signal came in stock AAA and your MT script create a text file with name AAA.txt in Desktop/Orders Folder.and write Trade Details Like SELL,AAA,AAA-EQ,MKT,MIS,AB0123,250
As soon as the the file is created,Vbs will read the file place Sell order in Pi and after Placing order will delete the text File.
This cycle keeps on Going until u stop the Vbscript.
In the same manner u can track multiple symbols also
Vbs will continuously watch folder for text file if any file text found
will open the file and read content and place order and delete file

Amazing Dedication Bro, Always a value add for newbie’s like me.
I will work on this, will get back to you with updates…thanks a lot

You are welcome to TradingQnA

Hi Again !!, The internal command of metatrader to make files just have permissions to record in MQ4 file folder… so can we use the mq4 folder itself to read the files

Folder doesn’t matter where it is…But the text file should be in the Format specified

Can the process be detailed step wise, pls

Hi rgv…
I will post the code tomorrow with details as I’m out of my city rightnow.

Hi, I tried your script but actually nothing happened. I simply follow your steps and put a file with same name and with your mentioned format, that suppose to be executed in PI, but nothing. Can you check or explaine little more what and how to do. Thanks

Hi…Raman…
Default, the .vbs file donot check for Error…
In the .vbs …Pls delete the line 'On Error Resume Next"
Re Run…the .vbs file…Ur Error will be shown…
Post the Error U got…From the Error We can figure out where is the Problem.