Experts/TM/Trade-Buy.mq5

70 lines
2.7 KiB
MQL5
Raw Permalink Normal View History

2025-05-30 14:54:10 +02:00
//+------------------------------------------------------------------+
//| Trade-Buy.mq5 |
//| Thorsten Fischer Copyright 2020 |
//| https://mql5.tfsystem.de |
//+------------------------------------------------------------------+
#property copyright "Thorsten Fischer Copyright 2020"
#property link "https://mql5.tfsystem.de"
#property version "1.00"
#include <Trade\Trade.mqh>
CTrade TestTrade;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
// string str="";
// TestTrade.LogLevel(LOG_LEVEL_ALL);
////Print(SYMBOL_FILLING_FOK);
////Print(SYMBOL_FILLING_IOC);
////Print(SYMBOL_FILLING_MODE);
// Print("Start Test = "+(bool)AccountInfoInteger(ACCOUNT_TRADE_ALLOWED));
////TestTrade.SetTypeFilling(ORDER_FILLING_RETURN);
// TestTrade.SetExpertMagicNumber(1234);
////if(TestTrade.SetTypeFillingBySymbol(Symbol()))
//// Print("True SetTypeFillingBySymbol");
////else
//// Print("False SetTypeFillingBySymbol");
// if(TestTrade.Buy(0.01))
// Print("True Buy");
// else
// Print("False Buy");
// TestTrade.PrintRequest();
// TestTrade.PrintResult();
printf("Start Test %s %s, Expert %s", AccountInfoString(ACCOUNT_COMPANY),
EnumToString((ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE)),
(AccountInfoInteger(ACCOUNT_TRADE_EXPERT) ? "Allowed" : "Disabled"));
TestTrade.SetExpertMagicNumber(1234);
//---
if(TestTrade.SetTypeFillingBySymbol(Symbol()))
Print("True SetTypeFillingBySymbol");
else
Print("False SetTypeFillingBySymbol");
//TestTrade.SetTypeFilling(ORDER_FILLING_RETURN);
//Print("SetTypeFillingBySymbol forced to ORDER_FILLING_RETURN");
//---
if(TestTrade.Buy(0.01))
Print("True Buy");
else
Print("False Buy");
Print("Ende "+(string)TestTrade.ResultRetcodeDescription());
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+