User login

  

ITradeComponent is the main interface for trading.

/// <summary> 
/// If trading allowed for the designed component,
/// it will implement this interface
/// </summary>
public interface ITradeComponent : IExternalComponent, IMessageListener
{
/// <summary>
/// Set or get the platorm engine for trading operations
/// It provides methods for platform functions calling
/// </summary>
/// <param name="platformEngine"></param>
IPlatformEngine PlatformEngine { get;set; }
}

ProTrader will create IPlatformEngine class and will set it through set-accessor property.

Note: Trading in custom component is allowed only when Automated Trading is allowed by Broker. In other case initialization of IPlatformEngine will be skipped.

All messages will be available through IMessageListener interface.

/// <summary> 
/// Message Listener Interface
/// </summary>
public interface IMessageListener
{

New message will be sent to this function with conversion to base class Message. You need to analyze message content and handle if needed. There are several methods in IPlatformEngine interface

 
public interface IPlatformEngine
{
string SubmitStrategyOrder(
 
 
string symbol, //Instrument to open Order (name as shown in PT)
int buysell, //Operation
double quoty, //Amount
double price, //Limit Price (at Market is ignored)
double stopPrice, //Stop Price (at Market is ignored)
int tif, //Time In Force
int orderType, //Type of Order
string account, //Account to open Order
string route, //Route to Open Order
long timeExpired, //Expired in (not supported yet – ignored)
string comment, //Comment to save on Server
string boundTo, //For OCO orders
double slOffset, //Stop Loss offset
double tpOffset, //Take Profit offset
double trOffset, //Trailing Stop offset
int mktRange, //Market Range (in pips)
int magicNumber, //Alternate ID
bool hedge); //Hedge on server. Shall be false.
 
string ClosePositions(
 
string orderId, //Position number
double lots, //Close amount
string symbol, //Instrument
string account); //Account
 
bool SetSLTP(
 
 
string orderId, //Order ID or Position Number
double sl, //New SL (set 0 to remove)
double tp, //New TP (set 0 to remove)
double ts);//New Trailing Stop (set 0 to remove)
 
bool ReplaceOrder(
 
string orderId,
double lots,
int tif,
double price,
double sl,
double tp,
string boundTo);
 
bool CancelOrder(
 
 
string orderId,
string symbol,
string account);
 
}

Operations:
VALUE_BUY = 10000; - Buy
VALUE_SELL = 10001; - Sell
 
TIFs
VALUE_DAY = 10011, - Day
VALUE_DAYPLUS = 10009, - Extended Day
VALUE_DAYNB = 10013, - for NY
VALUE_GTC = 10008,  - Good Till Cancel
VALUE_GTX = 10012, - Good Till Execute
VALUE_IOC = 10010, - Immediate or Cancel
VALUE_FOC = 11000; - Fill or Cancel

VALUE_AON = 10047,
 VALUE_COND_ORD_LMT = 10036,
 VALUE_COND_ORD_MKT = 10035,
 VALUE_DISCRETIONARY = 10043,
 VALUE_HIDDEN = 10041,
 VALUE_LIMIT = 10030,
 VALUE_LIMIT_CLOSE = 10057,
 VALUE_LIMIT_OPEN = 10056,
 VALUE_LIMIT_TRAIL = 10054,
 VALUE_LIMIT_TTO = 10050,
 VALUE_MARKET = 10031,
 VALUE_MARKET_CLOSE = 10039,
 VALUE_MARKET_OPEN = 10038,
 VALUE_MARKET_TRAIL = 10055,
 VALUE_MARKET_TTO = 10051,
 VALUE_NORMAL = 10042,
 VALUE_NOW = 10048,
 VALUE_PART = 10046,
 VALUE_PNP = 10045,
VALUE_RESERVE = 10040,
 VALUE_RSV_DISC = 10044,
 VALUE_RSV_TTO = 10052,
 VALUE_STOP_LIMIT = 10033,
 VALUE_STOP_MARKET = 10032,
 VALUE_STOP_TTO = 10053,
 VALUE_THRU = 10049,
 VALUE_TRAILING_STOP = 10034,
 VALUE_TTO_ORDER = 10037,
 VALUE_LIMIT_STOPMKT = 10064,
 VALUE_STOP_TRAIL = 10065,
 VALUE_RSV_PEGGED = 10066,
 VALUE_STOPLMT_TTO = 10067,
 VALUE_PEGGED = 10062,
 VALUE_VWAP = 10063,
 VALUE_STOPLMT_TRAIL = 10068,
 VALUE_STRADDLE = 10058,
 VALUE_STRANGLE = 10059,
 VALUE_OCO_ORDER = VALUE_TTO_ORDER,

VALUE_MANUAL = 10070, // Manual open 
VALUE_SLTP_LIMIT = 10071, // StopLoss and TakeProfit Limit
VALUE_SLTP_STOP = 10072, // StopLoss and TakeProfit Stop 
 
VALUE_STOP = 10073, // Stop Order
VALUE_POSITION = 10074, // Opened position
VALUE_TR_STOP = 10075; // Stop Order with Trailing Stop

12345