ent-testing/ProcessTrades.mqh
super.admin 1a8f6f22b7 convert
2025-05-30 14:53:02 +02:00

44 lines
1.7 KiB
MQL5

//+------------------------------------------------------------------+
//| ProcessTrades.mqh |
//| Entr04y |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Entr04y"
#property link "https://www.mql5.com"
//+------------------------------------------------------------------+
//| Process Open Trade |
//+------------------------------------------------------------------+
bool ProcessTradeOpen(ENUM_ORDER_TYPE orderType)
{
string CurrentSymbol = Symbol();
double price = 0;
double stopLossPrice = 0;
double takeProfitPrice = 0;
if(orderType == ORDER_TYPE_BUY)
{
price = NormalizeDouble(SymbolInfoDouble(CurrentSymbol, SYMBOL_ASK), Digits());
stopLossPrice = NormalizeDouble(price - 0.01, Digits());
takeProfitPrice = NormalizeDouble(price + 0.02, Digits());
}
else
if(orderType == ORDER_TYPE_SELL)
{
price = NormalizeDouble(SymbolInfoDouble(CurrentSymbol, SYMBOL_BID), Digits());
stopLossPrice = NormalizeDouble(price + 0.01, Digits());
takeProfitPrice = NormalizeDouble(price - 0.02, Digits());
}
// Get Lot Size
double lotSize = 1;
//Execute Trades
Trade.PositionClose(CurrentSymbol);
Trade.PositionOpen(CurrentSymbol, orderType, lotSize, price, stopLossPrice, takeProfitPrice, InpTradeComment);
// Error handling
return(true);
}
//+------------------------------------------------------------------+