test_script

Author: Copyright � 2005, Serega Lykov
Orders Execution
It automatically opens orders when conditions are reachedIt Closes Orders by itself
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 1499
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -6.09
Gross Profit 0.00
Gross Loss -9128.97
Total Net Profit -9128.97
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8125.68
Total Net Profit -8125.68
-100%
-50%
0%
50%
100%
test_script
//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                                   Copyright © 2005, Serega Lykov |
//|                                       http://mtexperts.narod.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Serega Lykov"
#property link      "http://mtexperts.narod.ru/"

int start()
  {
//---- OrderSelect() = false -----------------------------------------
//     return error: 4051 (ERR_INVALID_FUNCTION_PARAMVALUE)
//     message at logs: invalid ticket for OrderDelete function
   Print("1. ------------------------------------------------------");
   for(int i=1; i<100000; i++)
     {
      if(OrderSelect(i,SELECT_BY_TICKET) == true) continue;
      bool error = OrderDelete(OrderTicket(),CLR_NONE);
      if(error == false) Print("Error = ",GetLastError());
      break;
     } 
//---- delete order from history -------------------------------------
//     return error: 4108 (ERR_INVALID_TICKET)
//     message at logs: unknown ticket 24858529 for OrderDelete function
   Print("2. ------------------------------------------------------");
   int ticket = OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"",0,0,CLR_NONE);
   OrderClose(ticket,0.01,Bid,10,CLR_NONE);
   if(OrderSelect(ticket,SELECT_BY_TICKET) == true)
     {
      error = OrderDelete(OrderTicket(),CLR_NONE);
      if(error == false) Print("Error = ",GetLastError());
     }
//---- OrderSend() < 0  ----------------------------------------------
//     return error: 4051 (ERR_INVALID_FUNCTION_PARAMVALUE)
//     message at logs: invalid ticket for OrderDelete function
   Print("3. ------------------------------------------------------");
   ticket = OrderSend(Symbol(),OP_BUY,0.01,100000,3,0,0,"",0,0,CLR_NONE);
   error = OrderDelete(ticket,CLR_NONE);
   if(error == false) Print("Error = ",GetLastError()); 
//---- delete market order -------------------------------------------
//     return error: 4108 (ERR_INVALID_TICKET)
//     message at logs: market order #24859072 cannot be deleted
   Print("4. ------------------------------------------------------");
   ticket = OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"",0,0,CLR_NONE);
   error = OrderDelete(ticket,CLR_NONE);
   if(error == false)
     {
      Print("Error = ",GetLastError());
      OrderClose(ticket,0.01,Bid,10,CLR_NONE);
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---