Skip to content

CTrade

CTrade

CTrade is a class for easy access to the trade functions.

Description

CTrade class provides easy access to the trade functions.

Declaration

class CTrade : public CObject

Title

#include <Trade\Trade.mqh>

Inheritance hierarchy

CObject

CTrade

Direct descendants

: CExpertTrade

Class methods by groups

Setting parameters
LogLevelSets logging level
SetExpertMagicNumberSets the expert ID
SetDeviationInPointsSets the allowed deviation
SetTypeFillingSets filling type of the order
SetTypeFillingBySymbolSets filling type of the order according to the specified symbol settings
SetAsyncModeSets asynchronous mode for trade operations
SetMarginModeSets margin calculation mode in accordance with the current account settings
Operations with orders
OrderOpenPlaces a pending order with specified parameters
OrderModifyModifies the pending order parameters
OrderDeleteDeletes a pending order
Operations with positions
PositionOpenOpens a position with specified parameters
PositionModifyModifies position parameters by the specified symbol or position ticket
PositionCloseCloses a position for the specified symbol
PositionClosePartialPartially closes a position on a specified symbol or having a specified ticket
PositionCloseByCloses a position with the specified ticket by an opposite position
Additional methods
BuyOpens a long position with specified parameters
SellOpens a short position with specified parameters
BuyLimitPlaces a pending order of the Buy Limit type with specified parameters
BuyStopPlaces a pending order of the Buy Stop type with specified parameters
SellLimitPlaces a pending order of the Sell Limit type with specified parameters
SellStopPlaces a pending order of the Sell Stop type with specified parameters
Access to the last request parameters
RequestGets the copy of the last request structure
RequestActionGets the trade operation type
RequestActionDescriptionGets the trade operation type as string
RequestMagicGets the magic number of the Expert Advisor
RequestOrderGets the order ticket used in the last request
RequestSymbolGets the name of the symbol used in the last request
RequestVolumeGets the trade volume (in lots) used in the last request
RequestPriceGets the price used in the last request
RequestStopLimitGets the price of pending order of Stop Limit type used in the last request
RequestSLGets the Stop Loss price of the order used in the last request
RequestTPGets the Take Profit price of the order used in the last request
RequestDeviationGets the maximum allowable price deviation of the order used in the last request
RequestTypeGets the type of the order used in the last request
RequestTypeDescriptionGets the type of the order (as string) used in the last request
RequestTypeFillingGets the filling type of the order used in the last request
RequestTypeFillingDescriptionGets the filling type of the order (as string) used in the last request
RequestTypeTimeGets the validity period of the order used in the last request
RequestTypeTimeDescriptionGets the validity period of the order (as string) used in the last request
RequestExpirationGets the expiration time of the order used in the last request
RequestCommentGets the comment of the order used in the last request
RequestPositionGets position ticket
RequestPositionByGets opposite position ticket
Access to the last request checking results
CheckResultGets the copy of the structure of the last request check result.
CheckResultRetcodeGets the value of the retcode field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultRetcodeDescriptionGets the string description of the retcode field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultBalanceGets the value of the balance field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultEquityGets the value of the equity field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultProfitGets the value of the floating profit after executing a trading operation.
CheckResultMarginGets the value of the margin field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultMarginFreeGets the value of the margin_free field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultMarginLevelGets the value of the margin_level field of MqlTradeCheckResult type, filled while checking the request correctness
CheckResultCommentGets the value of the comment field of MqlTradeCheckResult type, filled while checking the request correctness
Access to the last request execution results
ResultGets the copy of the structure of the last request result
ResultRetcodeGets the code of request result
ResultRetcodeDescriptionGets the code of request result as a string
ResultDealGets the deal ticket
ResultOrderGets the order ticket
ResultVolumeGets the volume of deal or order
ResultPriceGets the price, confirmed by broker
ResultBidGets the current bid price (the requote)
ResultAskGets the current ask price (the requote)
ResultCommentGets the broker comment
Auxiliary methods
PrintRequestPrints the last request parameters into journal
PrintResultPrints the results of the last request into journal
FormatRequestPrepares the formatted string with last request parameters
FormatRequestResultPrepares the formatted string with results of the last request execution

Methods inherited from class CObject

: Prev, Prev, Next, Next, Save, Load, Type, Compare

Last updated on