orderstotal or ordershistorytotal not working

186 views
Skip to first unread message

bala...@gmail.com

unread,
Mar 18, 2014, 7:20:49 AM3/18/14
to nj...@googlegroups.com
I am new to this mt4 traders application, just following the c# step by step guide. I can able display account information and place new order. I just want to get the details of all orders and trying to implement OrdersTotal, but is throwing the following exception

System.Exception: MT4TerminalConnection: Client EURUSD.240.61902893(Forex Capital Markets, LLC) MQLv2.0.9@1468F9F3542ACF537D271A4F278083471 [i/o=45/72] disconnected (System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.BufferedStream.FlushWrite()
   at System.IO.BufferedStream.ReadByte()
   at nj4x.Net.MT4TerminalConnection.SendCommandGetResult(StringBuilder command))
   at nj4x.Net.MT4TerminalConnection.SendCommandGetResult(StringBuilder command)
   at nj4x.Metatrader.MT4.OrdersHistoryTotal()
   at nj4x_sbs_1.Program.Main(String[] args) in c:\Users\Administrator\Documents\SharpDevelop Projects\nj4x_sbs_1\nj4x_sbs_1\Program.cs:line 39

Some one please help on this to resolve the issue.

Regards,
Saravanan.B

Roman Gerasimenko

unread,
Mar 18, 2014, 7:23:54 AM3/18/14
to nj...@googlegroups.com
Can you attach Program.cs ?


--
You received this message because you are subscribed to the Google Groups "NJ4X Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nj4x+uns...@googlegroups.com.
To post to this group, send email to nj...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bala...@gmail.com

unread,
Mar 18, 2014, 7:44:49 AM3/18/14
to nj...@googlegroups.com
Hi,

Please find the below code.

using System;
using System.Configuration; 
using nj4x.Metatrader; 
 
namespace nj4x_sbs_1 

 class Program 
 { 
     static void Main(string[] args) 
     { 
         // Create strategy 
         var mt4 = new nj4x.Strategy(); 
         // Connect to the Terminal Server 
         
         mt4.Connect"127.0.0.1"7788
         mt4Server: new Broker(ConfigurationManager.AppSettings["broker"]), 
         mt4User: ConfigurationManager.AppSettings["account"], 
         mt4Password: ConfigurationManager.AppSettings["password"]
        );
         
        
         // Use API methods … 
         Console.WriteLine(String.Format("Account {0}", mt4.AccountNumber())); 
         Console.WriteLine(String.Format("Equity {0}", mt4.AccountEquity())); 
         
         double bid = mt4.Marketinfo(symbol: "EURUSD", type: MarketInfo.MODE_BID);
         double ask = mt4.Marketinfo("GBPUSD", MarketInfo.MODE_ASK);
         
         Console.WriteLine(String.Format("BID {0}", bid));
         Console.WriteLine(String.Format("ask {0}", ask));
    
         
         var s = new MyStrategy();
    
         //place order
         //s.place_order(bid, ask);
         
           
         int total = mt4.OrdersHistoryTotal();
         
         //Console.WriteLine("Total order:", total);
         
         // 
         Console.ReadLine(); 
         
    
         //s.order_history();
        //Console.ReadLine();
     } 
     
     
     
 } 
}

Regards,
Saravanan.B

Roman Gerasimenko

unread,
Mar 18, 2014, 7:46:31 AM3/18/14
to nj...@googlegroups.com
Please comment the line "var s = new MyStrategy();"

bala...@gmail.com

unread,
Mar 18, 2014, 7:47:34 AM3/18/14
to nj...@googlegroups.com
Hi,


Please find the below code,

bala...@gmail.com

unread,
Mar 18, 2014, 8:03:28 AM3/18/14
to nj...@googlegroups.com
Hi,

Thanks it is working, but not returning any count. I have 2 records in the MT4 terminal. Please check the attached screen shot.



Regards,
Saravanan.B

Roman Gerasimenko

unread,
Mar 18, 2014, 8:05:59 AM3/18/14
to nj...@googlegroups.com
Hi,

Please send me an email to sup...@nj4x.com

Reply all
Reply to author
Forward
0 new messages