|
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 CExpert |
Class Methods by Groups
Initialization |
|
---|---|
Class instance initialization method |
|
virtual InitSignal |
Initializes Trading Signal object |
virtual InitTrailing |
Initializes Trailing Stop object |
virtual InitMoney |
Initializes Money Management object |
virtual InitTrade |
Initializes Trade object |
virtual ValidationSettings |
Checks the settings |
virtual InitIndicators |
Initializes indicators and timeseries |
virtual InitParameters |
Expert Advisor parameters initialization method |
virtual Deinit |
Class instance deinitialization method |
virtual DeinitSignal |
Deinitializes Trading Signal object |
virtual DeinitTrailing |
Deinitializes Trailing Stop object |
virtual DeinitMoney |
Deinitializes Money Management object |
virtual DeinitTrade |
Deinitializes Trade object |
virtual DeinitIndicators |
Deinitializes indicators and timeseries |
Parameters |
|
Sets the Expert Advisor ID |
|
Gets/sets the maximum amount of allowed orders |
|
Sets a flag to proceed the "OnTick" event |
|
Sets a flag to proceed the "OnTrade" event |
|
Sets a flag to proceed the "OnTimer" event |
|
Sets a flag to proceed the "OnChartEvent" event |
|
Sets a flag to proceed the "OnBookEvent" event |
|
Event Processing Methods |
|
OnTick event handler |
|
OnTrade event handler |
|
OnTimer event handler |
|
OnChartEvent event handler |
|
OnBookEvent event handler |
|
Update Methods |
|
Updates all data |
|
Processing |
|
Main processing algorithm |
|
Market Entry Methods |
|
Checks position opening conditions |
|
Checks conditions to open long position |
|
Checks conditions to open short position |
|
Opens a long position |
|
Opens a short position |
|
Market Exit Methods |
|
Checks conditions to close current position |
|
Checks conditions to close long position |
|
Checks conditions to close short position |
|
Closes the opened position and deletes all orders |
|
Closes the opened position |
|
Closes the long position |
|
Closes the short position |
|
Position Reverse Methods |
|
Checks conditions to reverse opened position |
|
Checks conditions to reverse long position |
|
Checks conditions to reverse short position |
|
Performs reverse operation of long position |
|
Performs reverse operation of short position |
|
Position/Order Trailing Methods |
|
Checks conditions to modify position parameters |
|
Checks Trailing Stop conditions of long position |
|
Checks Trailing Stop conditions of short position |
|
Performs Trailing Stop for long position |
|
Performs Trailing Stop for short position |
|
Checks Trailing Stop conditions of Buy Limit/Stop order |
|
Checks Trailing Stop conditions of Sell Limit/Stop order |
|
Performs Trailing Stop for Buy Limit/Stop order |
|
Performs Trailing Stop for Sell Limit/Stop order |
|
Order Delete Methods |
|
Checks conditions to delete Buy order |
|
Checks conditions to delete Sell order |
|
Deletes all orders |
|
Deletes Stop/Limit order |
|
Deletes Buy Limit/Stop order |
|
Deletes Sell Limit/Stop order |
|
Trade Volume Methods |
|
Gets trade volume for buy operation |
|
Gets trade volume for sell operation |
|
Gets trade volume for position reverse operation |
|
Trade History Methods |
|
Sets starting date for trade history tracking |
|
Creates a checkpoint of trade history (saves number of positions, orders, deals and historical orders) |
|
Compares the current state with the saved one and calls the corresponding event handler |
|
Event flags |
|
Sets the trading event waiting flag |
|
Resets the trading event waiting flag |
|
Trade Event Processing Methods |
|
Event handler of the "Position Stop Loss/Take Profit triggered" event |
|
Event handler of the "Pending Order Triggered" event |
|
Event handler of the "Position Opened" event |
|
Event handler of the "Position Volume Changed" event |
|
Event handler of the "Position Modified" event |
|
Event handler of the "Position Closed" event |
|
Event handler of the "Pending Order Placed" event |
|
Event handler of the "Pending Order Modified" event |
|
Event handler of the "Pending Order Deleted" event |
|
Event handler of the non-identified event |
|
Service methods |
|
Adds a timeframe to track |
|
Forms timeframe flags |
|
Selects a position to work with |
Methods inherited from class CObject |
---|
Methods inherited from class CExpertBase InitPhase, TrendType, UsedSeries, EveryTick, Open, High, Low, Close, Spread, Time, TickVolume, RealVolume, Symbol, Period, Magic, SetMarginMode, SetPriceSeries, SetOtherSeries |