-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMACD Stochastic.mq5
564 lines (553 loc) · 49.3 KB
/
MACD Stochastic.mq5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
//+------------------------------------------------------------------+
//| MACD Stochastic(barabashkakvn's edition).mq5 |
//| Mikhail |
//| http://www.landofcash.net |
//+------------------------------------------------------------------+
#property copyright "Mikhail"
#property link "http://www.landofcash.net"
#property version "1.003"
//---
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
CPositionInfo m_position; // trade position object
CTrade m_trade; // trading object
CSymbolInfo m_symbol; // symbol info object
//--- input parameters
input int Inp_fast_ema_period = 12; // MACD: period for Fast average calculation
input int Inp_slow_ema_period = 26; // MACD: period for Slow average calculation
input int Inp_signal_period = 9; // MACD: period for their difference averaging
input bool Inp_use_Stoch = false; // Use Stochastic
input int Inp_bars_to_check_Stoch = 5; // Bars to check Stochastic
input int InpKperiod = 5; // STO: K-period (number of bars for calculations)
input int InpDperiod = 3; // STO: D-period (period of first smoothing)
input int Inp_slowing = 3; // STO: final smoothing
input ENUM_MA_METHOD Inp_ma_method = MODE_SMA; // STO: type of smoothing
input ENUM_STO_PRICE Inp_price_field = STO_LOWHIGH; // STO: stochastic calculation method
input double InpLots = 0.1; // Lots
input ushort InpStopLoss = 100; // Stop Loss (in pips)
input ushort InpTakeProfit = 100; // Take Profit (in pips)
input ushort InpTrailingStop = 0; // Trailing Stop (in pips)
input ushort InpTrailingStep = 5; // Trailing Step (in pips)
input int InpMaxPositions = 5; // Max positions
input ushort InpNoLossStop = 1; // No Loss stop (in pips)
input ushort InpWhenSetNoLossStop = 25; // When set "No Loss stop" (in pips)
input datetime InpStartPeriod_1=D'2017.10.10 08:15'; // Start period #1 (only hours and minutes are valid)
input datetime InpEndPeriod_1=D'2017.10.10 08:35'; // End period #1 (only hours and minutes are valid)
input datetime InpStartPeriod_2=D'2017.10.10 13:45'; // Start period #2 (only hours and minutes are valid)
input datetime InpEndPeriod_2=D'2017.10.10 14:42'; // End period #2 (only hours and minutes are valid)
input datetime InpStartPeriod_3=D'2017.10.10 22:15'; // Start period #3 (only hours and minutes are valid)
input datetime InpEndPeriod_3=D'2017.10.10 22:45'; // End period #3 (only hours and minutes are valid)
//---
string _ver=MQLInfoString(MQL_PROGRAM_NAME);
ulong m_magic=8889; // magic number
ulong m_slippage=10; // slippage
datetime _lastRun=0;
datetime _lastTimeOpenBar_0=0;
bool _isFirstTick=false;
//---
double ExtStopLoss=0.0;
double ExtTakeProfit=0.0;
double ExtTrailingStop=0.0;
double ExtTrailingStep=0.0;
double ExtNoLossStop=0.0;
double ExtWhenSetNoLossStop=0.0;
int handle_iMACD; // variable for storing the handle of the iMACD indicator
int handle_iStochastic; // variable for storing the handle of the iStochastic indicator
ENUM_ACCOUNT_MARGIN_MODE m_margin_mode;
double m_adjusted_point; // point value adjusted for 3 or 5 points
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
if(!m_symbol.Name(Symbol())) // sets symbol name
return(INIT_FAILED);
RefreshRates();
string err_text="";
if(!CheckVolumeValue(InpLots,err_text))
{
Print(err_text);
return(INIT_PARAMETERS_INCORRECT);
}
//---
m_trade.SetExpertMagicNumber(m_magic);
//---
if(IsFillingTypeAllowed(SYMBOL_FILLING_FOK))
m_trade.SetTypeFilling(ORDER_FILLING_FOK);
else if(IsFillingTypeAllowed(SYMBOL_FILLING_IOC))
m_trade.SetTypeFilling(ORDER_FILLING_IOC);
else
m_trade.SetTypeFilling(ORDER_FILLING_RETURN);
//---
m_trade.SetDeviationInPoints(m_slippage);
//--- tuning for 3 or 5 digits
int digits_adjust=1;
if(m_symbol.Digits()==3 || m_symbol.Digits()==5)
digits_adjust=10;
m_adjusted_point=m_symbol.Point()*digits_adjust;
ExtStopLoss=InpStopLoss*m_adjusted_point;
ExtTakeProfit=InpTakeProfit*m_adjusted_point;
ExtTrailingStop=InpTrailingStop*m_adjusted_point;
ExtTrailingStep=InpTrailingStep*m_adjusted_point;
ExtNoLossStop=InpNoLossStop*m_adjusted_point;
ExtWhenSetNoLossStop=InpWhenSetNoLossStop*m_adjusted_point;
//--- create handle of the indicator iMACD
handle_iMACD=iMACD(m_symbol.Name(),Period(),Inp_fast_ema_period,Inp_slow_ema_period,Inp_signal_period,PRICE_CLOSE);
//--- if the handle is not created
if(handle_iMACD==INVALID_HANDLE)
{
//--- tell about the failure and output the error code
PrintFormat("Failed to create handle of the iMACD indicator for the symbol %s/%s, error code %d",
m_symbol.Name(),
EnumToString(Period()),
GetLastError());
//--- the indicator is stopped early
return(INIT_FAILED);
}
//--- create handle of the indicator iStochastic
handle_iStochastic=iStochastic(m_symbol.Name(),Period(),InpKperiod,InpDperiod,Inp_slowing,Inp_ma_method,Inp_price_field);
//--- if the handle is not created
if(handle_iStochastic==INVALID_HANDLE)
{
//--- tell about the failure and output the error code
PrintFormat("Failed to create handle of the iStochastic indicator for the symbol %s/%s, error code %d",
m_symbol.Name(),
EnumToString(Period()),
GetLastError());
//--- the indicator is stopped early
return(INIT_FAILED);
}
if(InpNoLossStop>=InpWhenSetNoLossStop)
{
Print("\"No Loss stop\" can not be >= \"When set \"No Loss stop\"\"");
return(INIT_PARAMETERS_INCORRECT);
}
Print(_ver+" Started at "+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES));
Comment(_ver+" Started at "+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES));
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Comment("");
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if(TimeCurrent()-_lastRun>PeriodSeconds())
{
_lastRun=iTime(m_symbol.Name(),Period(),0);
Print("BarOpen:"+TimeToString(_lastRun,TIME_DATE|TIME_SECONDS)+" Current time:"+TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS));
_isFirstTick=true;
}
else
_isFirstTick=false;
ENUM_POSITION_TYPE needOpenType=-1;
int positions_number=CalculateAllPositions();
if(positions_number>0)
Trailing();
if(positions_number<InpMaxPositions && _lastTimeOpenBar_0<iTime(m_symbol.Name(),Period(),0))
{
needOpenType=NeedOpenType();
if(needOpenType==POSITION_TYPE_BUY || needOpenType==POSITION_TYPE_SELL)
if(!RefreshRates())
return;
if(needOpenType==POSITION_TYPE_BUY)
{
if(isGoodTime(InpStartPeriod_1,InpEndPeriod_1) ||
isGoodTime(InpStartPeriod_2,InpEndPeriod_2) ||
isGoodTime(InpStartPeriod_3,InpEndPeriod_3))
{
double sl=(InpStopLoss==0)?0.0:m_symbol.Ask()-ExtStopLoss;
double tp=(InpTakeProfit==0)?0.0:m_symbol.Ask()+ExtTakeProfit;
if(OpenBuy(sl,tp))
_lastTimeOpenBar_0=iTime(m_symbol.Name(),Period(),0);
}
}
if(needOpenType==POSITION_TYPE_SELL)
{
if(isGoodTime(InpStartPeriod_1,InpEndPeriod_1) ||
isGoodTime(InpStartPeriod_2,InpEndPeriod_2) ||
isGoodTime(InpStartPeriod_3,InpEndPeriod_3))
{
double sl=(InpStopLoss==0)?0.0:m_symbol.Bid()+ExtStopLoss;
double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
if(OpenSell(sl,tp))
_lastTimeOpenBar_0=iTime(m_symbol.Name(),Period(),0);
}
}
}
}
//+------------------------------------------------------------------+
//| Check Stochastic |
//+------------------------------------------------------------------+
bool CheckStoch(ENUM_POSITION_TYPE PositionType)
{
double mainCurrent = iStochasticGet(MAIN_LINE,0);
double signalCurrent = iStochasticGet(SIGNAL_LINE,0);
double main=0.0;
double signal=0.0;
if(signalCurrent<mainCurrent && PositionType==POSITION_TYPE_BUY)
{
for(int i=1;i<Inp_bars_to_check_Stoch;i++)
{
main = iStochasticGet(MAIN_LINE,i);
signal= iStochasticGet(SIGNAL_LINE,i);
}
if(signal>main)
return (true);
}
//---
if(signalCurrent>mainCurrent && PositionType==POSITION_TYPE_SELL)
{
for(int i=1;i<Inp_bars_to_check_Stoch;i++)
{
main = iStochasticGet(MAIN_LINE,i);
signal= iStochasticGet(SIGNAL_LINE,i);
}
if(signal<main)
return (true);
}
//---
return (false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
ENUM_POSITION_TYPE NeedOpenType()
{
double macdMain=iMACDGet(MAIN_LINE,0);
double macdSignal=iMACDGet(SIGNAL_LINE,0);
double macdMainPrev=iMACDGet(MAIN_LINE,1);
double macdSignalPrev=iMACDGet(SIGNAL_LINE,1);
if(macdMain>macdSignal && macdMainPrev<=macdSignalPrev && macdMain<0 && macdMainPrev<0)
{
if(!Inp_use_Stoch || CheckStoch(POSITION_TYPE_BUY))
return(POSITION_TYPE_BUY);
}
if(macdMain<macdSignal && macdMainPrev>=macdSignalPrev && macdMain>0 && macdMainPrev>0)
{
if(!Inp_use_Stoch || CheckStoch(POSITION_TYPE_SELL))
return(POSITION_TYPE_SELL);
}
return (-1);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool isGoodTime(datetime startAllowedDayTime,datetime endAllowedDayTime)
{
bool goodDay=true;
bool goodTime=false;
bool goodMinute=true;
MqlDateTime str_current;
MqlDateTime str_start;
MqlDateTime str_end;
TimeToStruct(TimeCurrent(),str_current);
TimeToStruct(startAllowedDayTime,str_start);
TimeToStruct(endAllowedDayTime,str_end);
if(goodDay)
{
//if hour greater or less STRICT!!!
if(str_current.hour>str_start.hour && str_current.hour<str_end.hour)
goodTime=true;
//if Hour is equal to Start hour then compare start minute
if(str_current.hour==str_start.hour)
{
goodTime=true;
if(str_current.min>=str_start.min)
goodMinute=goodMinute && true;
else
goodMinute=goodMinute && false;
}
//if Hour is equal to End hour then compare end minute
if(str_current.hour==str_end.hour)
{
goodTime=true;
if(str_current.min<=str_end.min)
goodMinute=goodMinute && true;
else
goodMinute=goodMinute && false;
}
}
if(!(goodDay && goodTime && goodMinute) && _isFirstTick)
{
Print("GoodTime false. TimeCurrent:"+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES)
+" _startAllowedDayTime:"+TimeToString(startAllowedDayTime,TIME_DATE|TIME_MINUTES)
+" _endAllowedDayTime"+TimeToString(endAllowedDayTime,TIME_DATE|TIME_MINUTES)
+" goodDay:"+IntegerToString(goodDay)+" goodTime:"+IntegerToString(goodTime));
}
return (goodDay&&goodTime&&goodMinute);
}
//+------------------------------------------------------------------+
//| Trailing |
//+------------------------------------------------------------------+
void Trailing()
{
if(ExtTrailingStop==0)
return;
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
if(m_position.SelectByIndex(i))
if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY)
{
if(m_position.PriceCurrent()-m_position.PriceOpen()>ExtWhenSetNoLossStop)
{
double sl=m_position.StopLoss()+ExtTrailingStop;
if(m_position.PriceCurrent()-ExtTrailingStep-ExtTrailingStop>sl && sl>m_position.PriceOpen()+ExtNoLossStop)
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(sl),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket(),
" Position -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
}
}
if(m_position.PositionType()==POSITION_TYPE_SELL)
{
if(m_position.PriceOpen()-m_position.PriceCurrent()>ExtWhenSetNoLossStop)
{
if(m_position.StopLoss()!=0.0)
{
double sl=m_position.StopLoss()-ExtTrailingStop;
if(m_position.PriceCurrent()+ExtTrailingStep+ExtTrailingStop<sl && sl<m_position.PriceOpen()-ExtNoLossStop)
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(sl),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket(),
" Position -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
}
else
{
double sl=m_position.PriceOpen()-ExtNoLossStop;
if(m_position.PriceCurrent()+ExtWhenSetNoLossStop<sl)
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(sl),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket(),
" Position -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
}
}
}
}
}
//+------------------------------------------------------------------+
//| Refreshes the symbol quotes data |
//+------------------------------------------------------------------+
bool RefreshRates()
{
//--- refresh rates
if(!m_symbol.RefreshRates())
{
Print("RefreshRates error");
return(false);
}
//--- protection against the return value of "zero"
if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
return(false);
//---
return(true);
}
//+------------------------------------------------------------------+
//| Check the correctness of the order volume |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume,string &error_description)
{
//--- minimal allowed volume for trade operations
double min_volume=m_symbol.LotsMin();
if(volume<min_volume)
{
error_description=StringFormat("Volume is less than the minimal allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);
return(false);
}
//--- maximal allowed volume of trade operations
double max_volume=m_symbol.LotsMax();
if(volume>max_volume)
{
error_description=StringFormat("Volume is greater than the maximal allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);
return(false);
}
//--- get minimal step of volume changing
double volume_step=m_symbol.LotsStep();
int ratio=(int)MathRound(volume/volume_step);
if(MathAbs(ratio*volume_step-volume)>0.0000001)
{
error_description=StringFormat("Volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f",
volume_step,ratio*volume_step);
return(false);
}
error_description="Correct volume value";
return(true);
}
//+------------------------------------------------------------------+
//| Checks if the specified filling mode is allowed |
//+------------------------------------------------------------------+
bool IsFillingTypeAllowed(int fill_type)
{
//--- Obtain the value of the property that describes allowed filling modes
int filling=m_symbol.TradeFillFlags();
//--- Return true, if mode fill_type is allowed
return((filling & fill_type)==fill_type);
}
//+------------------------------------------------------------------+
//| Calculate all positions |
//+------------------------------------------------------------------+
int CalculateAllPositions()
{
int total=0;
for(int i=PositionsTotal()-1;i>=0;i--)
if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
total++;
//---
return(total);
}
//+------------------------------------------------------------------+
//| Get value of buffers for the iMACD |
//| the buffer numbers are the following: |
//| 0 - MAIN_LINE, 1 - SIGNAL_LINE |
//+------------------------------------------------------------------+
double iMACDGet(const int buffer,const int index)
{
double MACD[1];
//--- reset error code
ResetLastError();
//--- fill a part of the iMACDBuffer array with values from the indicator buffer that has 0 index
if(CopyBuffer(handle_iMACD,buffer,index,1,MACD)<0)
{
//--- if the copying fails, tell the error code
PrintFormat("Failed to copy data from the iMACD indicator, error code %d",GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculated
return(0.0);
}
return(MACD[0]);
}
//+------------------------------------------------------------------+
//| Get value of buffers for the iStochastic |
//| the buffer numbers are the following: |
//| 0 - MAIN_LINE, 1 - SIGNAL_LINE |
//+------------------------------------------------------------------+
double iStochasticGet(const int buffer,const int index)
{
double Stochastic[1];
//--- reset error code
ResetLastError();
//--- fill a part of the iStochasticBuffer array with values from the indicator buffer that has 0 index
if(CopyBuffer(handle_iStochastic,buffer,index,1,Stochastic)<0)
{
//--- if the copying fails, tell the error code
PrintFormat("Failed to copy data from the iStochastic indicator, error code %d",GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculated
return(0.0);
}
return(Stochastic[0]);
}
//+------------------------------------------------------------------+
//| Open Buy position |
//+------------------------------------------------------------------+
bool OpenBuy(double sl,double tp)
{
sl=m_symbol.NormalizePrice(sl);
tp=m_symbol.NormalizePrice(tp);
//--- check volume before OrderSend to avoid "not enough money" error (CTrade)
double check_volume_lot=m_trade.CheckVolume(m_symbol.Name(),InpLots,m_symbol.Ask(),ORDER_TYPE_BUY);
if(check_volume_lot!=0.0)
if(check_volume_lot>=InpLots)
{
if(m_trade.Buy(InpLots,NULL,m_symbol.Ask(),sl,tp))
{
if(m_trade.ResultDeal()==0)
{
Print("#1 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResult(m_trade,m_symbol);
return(false);
}
else
{
Print("#2 Buy -> true. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResult(m_trade,m_symbol);
return(true);
}
}
else
{
Print("#3 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResult(m_trade,m_symbol);
return(false);
}
}
//---
return(false);
}
//+------------------------------------------------------------------+
//| Open Sell position |
//+------------------------------------------------------------------+
bool OpenSell(double sl,double tp)
{
sl=m_symbol.NormalizePrice(sl);
tp=m_symbol.NormalizePrice(tp);
//--- check volume before OrderSend to avoid "not enough money" error (CTrade)
double check_volume_lot=m_trade.CheckVolume(m_symbol.Name(),InpLots,m_symbol.Bid(),ORDER_TYPE_SELL);
if(check_volume_lot!=0.0)
if(check_volume_lot>=InpLots)
{
if(m_trade.Sell(InpLots,NULL,m_symbol.Bid(),sl,tp))
{
if(m_trade.ResultDeal()==0)
{
Print("#1 Sell -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResult(m_trade,m_symbol);
return(false);
}
else
{
Print("#2 Sell -> true. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResult(m_trade,m_symbol);
return(true);
}
}
else
{
Print("#3 Sell -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResult(m_trade,m_symbol);
return(false);
}
}
//---
return(false);
}
//+------------------------------------------------------------------+
//| Print CTrade result |
//+------------------------------------------------------------------+
void PrintResult(CTrade &trade,CSymbolInfo &symbol)
{
Print("Code of request result: "+IntegerToString(trade.ResultRetcode()));
Print("code of request result: "+trade.ResultRetcodeDescription());
Print("deal ticket: "+IntegerToString(trade.ResultDeal()));
Print("order ticket: "+IntegerToString(trade.ResultOrder()));
Print("volume of deal or order: "+DoubleToString(trade.ResultVolume(),2));
Print("price, confirmed by broker: "+DoubleToString(trade.ResultPrice(),symbol.Digits()));
Print("current bid price: "+DoubleToString(trade.ResultBid(),symbol.Digits()));
Print("current ask price: "+DoubleToString(trade.ResultAsk(),symbol.Digits()));
Print("broker comment: "+trade.ResultComment());
DebugBreak();
}
//+------------------------------------------------------------------+