//+------------------------------------------------------------------+ //| Demo_CTrade.mq5 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #include //--- object for performing trade operations CTrade trade; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- set MagicNumber for your orders identification int MagicNumber=123456; trade.SetExpertMagicNumber(MagicNumber); //--- set available slippage in points when buying/selling int deviation=10; trade.SetDeviationInPoints(deviation); //--- order execution mode trade.SetTypeFilling(ORDER_FILLING_RETURN); //--- logging mode trade.LogLevel(1); // it would be better not to declare this method at all, the class will set the best mode on its own //--- what function is to be used for trading: true - OrderSendAsync(), false - OrderSend() trade.SetAsyncMode(true); //--- return(0); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+