I'll try to detail here what the robot doesCopyTrader - Detailed Operation
54032CopyTrader - Detailed OperationOnInit(
)
Creates/opens the SQLite database"CopyTrader.sqlite"
Creates two tables if they don't exist:
signals: to store active signals signals_history: to store signal history
Initial Check (CheckInitialOrders)
Checks all open positions, for each position with the correct MAGIC_NUMBER: Records in the bank as a "NEW" signal Stores in control arrays (previous_orders and previous_positions)
OnTradeTransaction()
Modification of SL/TP(TRADE_TRANSACTION_REQUEST)
Detects whenSL/TPismodified (TRADE_ACTION_SLTP) Checks if the position belongs to EA (MAGIC_NUMBER) Sends "MODIFY" signal to the bank with new values
New Position (TRADE_TRANSACTION_DEAL_ADD)
Detects when a new position is opened Checks whether it's a buy or sell (DEAL_TYPE_BUY or DEAL_TYPE_SELL) Checks MAGIC_NUMBER
If it's an entry (DEAL_ENTRY_IN): Sends "NEW" signal to bank with position details
- Position closure (TRADE_TRANSACTION_HISTORY_ADD)
Detects when a position is closed Checks history of deals If it finds an exit (DEAL_ENTRY_OUT): Sends "CLOSE" signal to the bank
Signal Functions
1.SendNewOrderSignal
Registersa new order with the bank Stores ticket, symbol, type, volume, price, SL and TP SendModifySignal Registers order modification in the bank Updates SL and TP SendCloseSignal Records order closure in the bank Marks order as closed
Database(CSignalDB)
WriteSignal Adds new signals to the database Checks for duplicate "NEW" signals UpdateSignalStatus Updates signal status MoveToHistory Moves completed signals to history table GetPendingSignals Retrieves pending signals from the bank