File tree 1 file changed +54
-0
lines changed
1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1
1
# MTsocketAPI C# Libraries
2
2
3
3
Libraries created to help developers to easily use the MTsocketAPI using C#
4
+
5
+ Basic Usage:
6
+
7
+ ``` csharp
8
+ using MTsocketAPI .MT5 ;
9
+ using System .Security .Cryptography ;
10
+
11
+ namespace Test
12
+ {
13
+ internal class Program
14
+ {
15
+ static void Main (string [] args )
16
+ {
17
+ try
18
+ {
19
+ Console .WriteLine (" #### MTsocketAPI C# Library ####" );
20
+
21
+ MTsocketAPI .MT5 .Terminal mt5 = new MTsocketAPI .MT5 .Terminal ();
22
+
23
+ if (! mt5 .Connect ())
24
+ {
25
+ Console .WriteLine (" Error connecting to MTsocketAPI. Please check if MT5 is running and MTsocketAPI started successfully" );
26
+ return ;
27
+ }
28
+
29
+ Quote quote = mt5 .GetQuote (" EURUSD" );
30
+
31
+ Console .WriteLine (quote .SYMBOL + " Time: " + quote .TIME + " Ask: " + quote .ASK + " Bid: " + quote .BID );
32
+
33
+ Asset asset = mt5 .GetSymbolInfo (" EURUSD" );
34
+
35
+ Console .WriteLine (asset .ToString ());
36
+
37
+ Console .WriteLine (" \n Press any key to send one buy order to MT5..." );
38
+ Console .ReadKey (true );
39
+ TradeResult buy = mt5 .SendOrder (asset .NAME , asset .VOLUME_MIN , OrderType .ORDER_TYPE_BUY );
40
+ Console .WriteLine (" Result:" + buy .ToString ());
41
+
42
+ Console .WriteLine (" \n Press any key to close the order..." );
43
+ Console .ReadKey (true );
44
+ TradeResult close = mt5 .OrderClose (buy .ORDER );
45
+ Console .WriteLine (" Result:" + close .ToString ());
46
+
47
+ Console .WriteLine (" Finished!" );
48
+ }
49
+ catch (Exception ex )
50
+ {
51
+ Console .WriteLine ($" Error: {ex .Message }" );
52
+ return ;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
You can’t perform that action at this time.
0 commit comments