Debug 2
MT4: double aTrade[][MAX_FIELDS]
C++:
vector<int> aTrade0;//PROP_Ticket=0
vector<int> aTrade1;//PROP_OpenDT=1
vector<int> aTrade2;//PROP_Type=2 (int cmd)
vector<double> aTrade3;//PROP_Lots=3 (double volume)
vector<double> aTrade4;//PROP_OpenPrice=4 (double price)
vector<double> aTrade5;//PROP_SL=5 (double stoploss)
vector<double> aTrade6;//PROP_TP=6 (double takeprofit)
vector<int> aTrade7;//PROP_Magic=7 (int magic)
vector<double> aTrade8;//PROP_ExpDT=8 (int expiration)
vector<double> aTrade9;//PROP_ClosePrice=9
vector<int> aTrade10;//PROP_CloseDT=10
vector<double> aTrade11;//PROP_Profit=11
vector<int> aTrade12;//PROP_LastRecalcDT=12
vector<double> aTrade13;//PROP_MaxDD=13
vector<double> aTrade14;//PROP_MaxProfit=14
MT4: double aHistory[][MAX_FIELDS]
C++:
vector<int> aHistory0;//PROP_Ticket=0
vector<int> aHistory1;//PROP_OpenDT=1
vector<int> aHistory2;//PROP_Type=2 (int cmd)
vector<double> aHistory3;//PROP_Lots=3 (double volume)
vector<double> aHistory4;//PROP_OpenPrice=4 (double price)
vector<double> aHistory5;//PROP_SL=5 (double stoploss)
vector<double> aHistory6;//PROP_TP=6 (double takeprofit)
vector<int> aHistory7;//PROP_Magic=7 (int magic)
vector<double> aHistory8;//PROP_ExpDT=8 (int expiration)
vector<double> aHistory9;//PROP_ClosePrice=9
vector<int> aHistory10;//PROP_CloseDT=10
vector<double> aHistory11;//PROP_Profit=11
vector<int> aHistory12;//PROP_LastRecalcDT=12
vector<double> aHistory13;//PROP_MaxDD=13
vector<double> aHistory14;//PROP_MaxProfit=14
int _aHistory_cnt_;//ArrayResize_aHistory()
int _aHistory_p_; //OrderSelect()
#include "main.hpp"
int main()
{
init_mt4(MT4);
int pos1 = 10;
int pos2 = 100;
int i;
string symbol=_Sym_[11];//EURUSD
int cmd= OP_BUY;
int SP=MarketInfo(symbol,MODE_SPREAD);
int TP=50;
int SL=50;
double Point=MarketInfo(symbol,MODE_POINT);;
double Bid1=iClose(symbol,PERIOD_M1,pos1);
double Bid2=iClose(symbol,PERIOD_M1,pos2);
int time1 = iTime(symbol,PERIOD_M1,pos1);
int time2 = iTime(symbol,PERIOD_M1,pos2);
double Spread=SP*Point;
double Ask1=Bid1+Spread;
double Ask2=Bid2+Spread;
double price1=Ask1;
double price2=Ask2;
int slippage=3;
double stoploss1=Ask1-SL*Point;
double takeprofit1=Ask1+TP*Point;
double stoploss2=Ask2-SL*Point;
double takeprofit2=Ask2+TP*Point;
double volume=0.1;
string comment="Buy Order";
int magic=0;
int expiration=0;
cout << "OrdersTotal()="<< OrdersTotal() << endl;
int r1=OrderSend(symbol, cmd, volume, price1, slippage, stoploss1, takeprofit1, comment, magic, expiration);
cout << r1 << " OrdersTotal()="<< OrdersTotal() << endl;
int r2=OrderSend(symbol, cmd, volume, price2, slippage, stoploss2, takeprofit2, comment, magic, expiration);
cout << r2 << " OrdersTotal()="<< OrdersTotal() << endl;
//////////////////////////////////////////////
cout << endl;
/*
extern vector<int> aTrade0;//PROP_Ticket=0
extern vector<int> aTrade1;//PROP_OpenDT=1
extern vector<int> aTrade2;//PROP_Type=2 (int cmd)
extern vector<double> aTrade3;//PROP_Lots=3 (double volume)
extern vector<double> aTrade4;//PROP_OpenPrice=4 (double price)
extern vector<double> aTrade5;//PROP_SL=5 (double stoploss)
extern vector<double> aTrade6;//PROP_TP=6 (double takeprofit)
extern vector<int> aTrade7;//PROP_Magic=7 (int magic)
extern vector<double> aTrade8;//PROP_ExpDT=8 (int expiration)
extern vector<double> aTrade9;//PROP_ClosePrice=9
extern vector<int> aTrade10;//PROP_CloseDT=10
extern vector<double> aTrade11;//PROP_Profit=11
extern vector<int> aTrade12;//PROP_LastRecalcDT=12
extern vector<double> aTrade13;//PROP_MaxDD=13
extern vector<double> aTrade14;//PROP_MaxProfit=14
*/
int ord = 1;
OrderSelect( ord, SELECT_BY_TICKET, MODE_TRADES);
cout << "_aTrade_p_=" << _aTrade_p_ << " Order Pos = " << pos1 << " Order Time = " << time1 << endl;
cout << "AccountCurrency()=" << AccountCurrency() << endl;
cout << aTrade0[ord-1] << " OrderTicket()=" << OrderTicket() << endl;
cout << aTrade1[ord-1] << " OrderOpenTime()=" << OrderOpenTime() << endl;
cout << aTrade2[ord-1] << " OrderType()=" << OrderType() << endl;
cout << aTrade3[ord-1] << " OrderLots()=" << OrderLots() << endl;
cout << aTrade4[ord-1] << " OrderOpenPrice()=" << OrderOpenPrice() << endl;
cout << aTrade5[ord-1] << " OrderStopLoss()=" << OrderStopLoss() << endl;
cout << aTrade6[ord-1] << " OrderTakeProfit()=" << OrderTakeProfit() << endl;
cout << aTrade7[ord-1] << " OrderMagicNumber()=" << OrderMagicNumber() << endl;
cout << aTrade8[ord-1] << " OrderExpiration()=" << OrderExpiration() << endl;
cout << aTrade9[ord-1] << " OrderClosePrice()=" << OrderClosePrice() << endl;
cout << aTrade10[ord-1] << " OrderCloseTime()=" << OrderCloseTime() << endl;
cout << aTrade11[ord-1] << " OrderProfit()=" << OrderProfit() << endl;
cout << aTrade_strings0[ord-1] << " OrderSymbol()=" << OrderSymbol() << endl;
cout << aTrade_strings1[ord-1] << " OrderComment()=" << OrderComment() << endl;
cout << endl;
/////////////////////////////////////////////
ord = 2;
OrderSelect( ord, SELECT_BY_TICKET, MODE_TRADES);
cout << "_aTrade_p_=" << _aTrade_p_ << " Order Pos = " << pos2 << " Order Time = " << time2 << endl;
cout << " AccountCurrency()=" << AccountCurrency() << endl;
cout << aTrade0[ord-1] << " OrderTicket()=" << OrderTicket() << endl;
cout << aTrade1[ord-1] << " OrderOpenTime()=" << OrderOpenTime() << endl;
cout << aTrade2[ord-1] << " OrderType()=" << OrderType() << endl;
cout << aTrade3[ord-1] << " OrderLots()=" << OrderLots() << endl;
cout << aTrade4[ord-1] << " OrderOpenPrice()=" << OrderOpenPrice() << endl;
cout << aTrade5[ord-1] << " OrderStopLoss()=" << OrderStopLoss() << endl;
cout << aTrade6[ord-1] << " OrderTakeProfit()=" << OrderTakeProfit() << endl;
cout << aTrade7[ord-1] << " OrderMagicNumber()=" << OrderMagicNumber() << endl;
cout << aTrade8[ord-1] << " OrderExpiration()=" << OrderExpiration() << endl;
cout << aTrade9[ord-1] << " OrderClosePrice()=" << OrderClosePrice() << endl;
cout << aTrade10[ord-1] << " OrderCloseTime()=" << OrderCloseTime() << endl;
cout << aTrade11[ord-1] << " OrderProfit()=" << OrderProfit() << endl;
cout << aTrade_strings0[ord-1] << " OrderSymbol()=" << OrderSymbol() << endl;
cout << aTrade_strings1[ord-1] << " OrderComment()=" << OrderComment() << endl;
cout << endl;
/////////////////////////////////////////////
cout << " OrdersTotal()="<< OrdersTotal() << endl;
cout << " OrdersHistoryTotal()="<< OrdersHistoryTotal() << endl;
DebugPrintArrays("0");
ord=1;
OrderSelect(ord,SELECT_BY_TICKET,MODE_TRADES);
if(OrderType()==OP_BUY)
OrderClose(ord,OrderLots(),Bid1,slippage);
else if(OrderType()==OP_SELL)
OrderClose(ord,OrderLots(),Ask1,slippage);
cout << " OrdersTotal()="<< OrdersTotal() << endl;
cout << " OrdersHistoryTotal()="<< OrdersHistoryTotal() << endl;
DebugPrintArrays("1");
ord=1;
OrderSelect(ord,SELECT_BY_TICKET,MODE_TRADES);
if(OrderType()==OP_BUY)
OrderClose(ord,OrderLots(),Bid2,slippage);
else if(OrderType()==OP_SELL)
OrderClose(ord,OrderLots(),Ask2,slippage);
cout << " OrdersTotal()="<< OrdersTotal() << endl;
cout << " OrdersHistoryTotal()="<< OrdersHistoryTotal() << endl;
DebugPrintArrays("2");
//////////////////////////////////////////////
cout << endl;
ord=1;
OrderSelect( ord, SELECT_BY_TICKET, MODE_HISTORY);
cout << aHistory0[ord-1] << " OrderTicket()=" << OrderTicket() << endl;
cout << aHistory1[ord-1] << " OrderOpenTime()=" << OrderOpenTime() << endl;
cout << aHistory2[ord-1] << " OrderType()=" << OrderType() << endl;
cout << aHistory3[ord-1] << " OrderLots()=" << OrderLots() << endl;
cout << aHistory4[ord-1] << " OrderOpenPrice()=" << OrderOpenPrice() << endl;
cout << aHistory5[ord-1] << " OrderStopLoss()=" << OrderStopLoss() << endl;
cout << aHistory6[ord-1] << " OrderTakeProfit()=" << OrderTakeProfit() << endl;
cout << aHistory7[ord-1] << " OrderMagicNumber()=" << OrderMagicNumber() << endl;
cout << aHistory8[ord-1] << " OrderExpiration()=" << OrderExpiration() << endl;
cout << aHistory9[ord-1] << " OrderClosePrice()=" << OrderClosePrice() << endl;
cout << aHistory10[ord-1] << " OrderCloseTime()=" << OrderCloseTime() << endl;
cout << aHistory11[ord-1] << " OrderProfit()=" << OrderProfit() << endl;
cout << aHistory_strings0[ord-1] << " OrderSymbol()=" << OrderSymbol() << endl;
cout << aHistory_strings1[ord-1] << " OrderComment()=" << OrderComment() << endl;
cout << endl;
/////////////////////////////////////////////
ord=2;
OrderSelect( ord, SELECT_BY_TICKET, MODE_HISTORY);
cout << aHistory0[ord-1] << " OrderTicket()=" << OrderTicket() << endl;
cout << aHistory1[ord-1] << " OrderOpenTime()=" << OrderOpenTime() << endl;
cout << aHistory2[ord-1] << " OrderType()=" << OrderType() << endl;
cout << aHistory3[ord-1] << " OrderLots()=" << OrderLots() << endl;
cout << aHistory4[ord-1] << " OrderOpenPrice()=" << OrderOpenPrice() << endl;
cout << aHistory5[ord-1] << " OrderStopLoss()=" << OrderStopLoss() << endl;
cout << aHistory6[ord-1] << " OrderTakeProfit()=" << OrderTakeProfit() << endl;
cout << aHistory7[ord-1] << " OrderMagicNumber()=" << OrderMagicNumber() << endl;
cout << aHistory8[ord-1] << " OrderExpiration()=" << OrderExpiration() << endl;
cout << aHistory9[ord-1] << " OrderClosePrice()=" << OrderClosePrice() << endl;
cout << aHistory10[ord-1] << " OrderCloseTime()=" << OrderCloseTime() << endl;
cout << aHistory11[ord-1] << " OrderProfit()=" << OrderProfit() << endl;
cout << aHistory_strings0[ord-1] << " OrderSymbol()=" << OrderSymbol() << endl;
cout << aHistory_strings1[ord-1] << " OrderComment()=" << OrderComment() << endl;
cout << endl;
/////////////////////////////////////////////
//cout << "aTrade0[0]" << endl;
//cout << aTrade0[0] << endl; //PROP_Ticket=0
//cout << "OrdersHistoryTotal()="<< OrdersHistoryTotal() << endl;
return 0;
}
int _aTrade_cnt_;//AccountBalance()
int _aTrade_p_; //OrderSelect()
int _aTrade_CurrentDT_;
MT4:
int aHistory.cnt = 0;
int aHistory.p=-1; //pointer position in the array of current orders
C++:
MT4:
int aTrade.cnt = 0;
int aTrade.p=-1; //pointer position in the array of current orders
C++: