#include "stdafx.h"
using namespace System;
using namespace System::Threading;
using namespace TradingAPI::MT4Server;
int _tmain(void)
{
try
{
MainServer^ srv = QuoteClient::LoadSrv("GerchikCo-Demo.srv");
QuoteClient^ qc = gcnew QuoteClient(67611, "wx1yhpn", srv->Host, srv->Port);
Console::WriteLine("Connecting...");
qc->Connect();
OrderClient^ oc = gcnew OrderClient(qc);
oc->Connect();
Console::WriteLine("Connected to server. Balance = " + qc->AccountBalance);
while (qc->GetQuote("EURUSD") == nullptr)
Thread::Sleep(10);
double ask = qc->GetQuote("EURUSD")->Ask;
Order^ order = oc->OrderSend(gcnew String("EURUSD"), Op::Buy, 0.1, ask, 0, 0.0, 0.0, gcnew String(""), 0, DateTime::MinValue);
Console::WriteLine("Order " + order->Ticket + " opened");
Console::WriteLine("Press any key...");
Console::ReadKey();
qc->Disconnect();
oc->Disconnect();
}
catch (Exception^ ex)
{
Console::WriteLine(ex->Message);
Console::WriteLine("Press any key...");
Console::ReadKey();
}
return 0;
}