Skip to content

CExpert

CExpert

CExpert is a base class for trading strategies.

It already has some elementary trading “skills”. It has built-in algorithms for working with time series and indicators and a set of virtual methods for trading strategy.

How to use it:

  1. Prepare an algorithm of the strategy;
  2. Create your own class, inherited from CExpert class;
  3. Override the virtual methods in your class with your own algorithms.

Description

The CExpert class is a set of virtual methods for implementation of trading strategies.

Note

A position is recognized as belonging to an Expert Advisor and managed by it based on the pair of properties m_symbol and m_magic. In the “hedging” mode, multiple positions can be opened for the same symbol, therefore the m_magic value is important.

Declaration

class CExpert : public CExpertBase

Title

#include <Expert\Expert.mqh>

Inheritance hierarchy

CObject

CExpertBase

CExpert

Class Methods by Groups

Initialization
InitClass instance initialization method
virtual InitSignalInitializes Trading Signal object
virtual InitTrailingInitializes Trailing Stop object
virtual InitMoneyInitializes Money Management object
virtual InitTradeInitializes Trade object
virtual ValidationSettingsChecks the settings
virtual InitIndicatorsInitializes indicators and timeseries
virtual InitParametersExpert Advisor parameters initialization method
virtual DeinitClass instance deinitialization method
virtual DeinitSignalDeinitializes Trading Signal object
virtual DeinitTrailingDeinitializes Trailing Stop object
virtual DeinitMoneyDeinitializes Money Management object
virtual DeinitTradeDeinitializes Trade object
virtual DeinitIndicatorsDeinitializes indicators and timeseries
Parameters
MagicSets the Expert Advisor ID
MaxOrdersGets/sets the maximum amount of allowed orders
OnTickProcessSets a flag to proceed the “OnTick” event
OnTradeProcessSets a flag to proceed the “OnTrade” event
OnTimerProcessSets a flag to proceed the “OnTimer” event
OnChartEventProcessSets a flag to proceed the “OnChartEvent” event
OnBookEventProcessSets a flag to proceed the “OnBookEvent” event
Event Processing Methods
OnTickOnTick event handler
OnTradeOnTrade event handler
OnTimerOnTimer event handler
OnChartEventOnChartEvent event handler
OnBookEventOnBookEvent event handler
Update Methods
RefreshUpdates all data
Processing
ProcessingMain processing algorithm
Market Entry Methods
CheckOpenChecks position opening conditions
CheckOpenLongChecks conditions to open long position
CheckOpenShortChecks conditions to open short position
OpenLongOpens a long position
OpenShortOpens a short position
Market Exit Methods
CheckCloseChecks conditions to close current position
CheckCloseLongChecks conditions to close long position
CheckCloseShortChecks conditions to close short position
CloseAllCloses the opened position and deletes all orders
CloseCloses the opened position
CloseLongCloses the long position
CloseShortCloses the short position
Position Reverse Methods
CheckReverseChecks conditions to reverse opened position
CheckReverseLongChecks conditions to reverse long position
CheckReverseShortChecks conditions to reverse short position
ReverseLongPerforms reverse operation of long position
ReverseShortPerforms reverse operation of short position
Position/Order Trailing Methods
CheckTrailingStopChecks conditions to modify position parameters
CheckTrailingStopLongChecks Trailing Stop conditions of long position
CheckTrailingStopShortChecks Trailing Stop conditions of short position
TrailingStopLongPerforms Trailing Stop for long position
TrailingStopShortPerforms Trailing Stop for short position
CheckTrailingOrderLongChecks Trailing Stop conditions of Buy Limit/Stop order
CheckTrailingOrderShortChecks Trailing Stop conditions of Sell Limit/Stop order
TrailingOrderLongPerforms Trailing Stop for Buy Limit/Stop order
TrailingOrderShortPerforms Trailing Stop for Sell Limit/Stop order
Order Delete Methods
CheckDeleteOrderLongChecks conditions to delete Buy order
CheckDeleteOrderShortChecks conditions to delete Sell order
DeleteOrdersDeletes all orders
DeleteOrderDeletes Stop/Limit order
DeleteOrderLongDeletes Buy Limit/Stop order
DeleteOrderShortDeletes Sell Limit/Stop order
Trade Volume Methods
LotOpenLongGets trade volume for buy operation
LotOpenShortGets trade volume for sell operation
LotReverseGets trade volume for position reverse operation
Trade History Methods
PrepareHistoryDateSets starting date for trade history tracking
HistoryPointCreates a checkpoint of trade history (saves number of positions, orders, deals and historical orders)
CheckTradeStateCompares the current state with the saved one and calls the corresponding event handler
Event flags
WaitEventSets the trading event waiting flag
NoWaitEventResets the trading event waiting flag
Trade Event Processing Methods
TradeEventPositionStopTakeEvent handler of the “Position Stop Loss/Take Profit triggered” event
TradeEventOrderTriggeredEvent handler of the “Pending Order Triggered” event
TradeEventPositionOpenedEvent handler of the “Position Opened” event
TradeEventPositionVolumeChangedEvent handler of the “Position Volume Changed” event
TradeEventPositionModifiedEvent handler of the “Position Modified” event
TradeEventPositionClosedEvent handler of the “Position Closed” event
TradeEventOrderPlacedEvent handler of the “Pending Order Placed” event
TradeEventOrderModifiedEvent handler of the “Pending Order Modified” event
TradeEventOrderDeletedEvent handler of the “Pending Order Deleted” event
TradeEventNotIdentifiedEvent handler of the non-identified event
Service methods
TimeframeAddAdds a timeframe to track
TimeframesFlagsForms timeframe flags
SelectPositionSelects a position to work with

Methods inherited from class CExpertBase

: InitPhase, TrendType, UsedSeries, EveryTick, Open, High, Low, Close, Spread, Time, TickVolume, RealVolume, Symbol, Period, Magic, SetMarginMode, SetPriceSeries, SetOtherSeries

Last updated on