SMC_BOS_EA/PRINCE

228 lines
3.8 KiB
Text
Raw Permalink Normal View History

2026-06-14 11:22:27 +00:00
#property strict
2026-06-17 13:52:11 +00:00
#include <Trade/Trade.mqh>
CTrade trade;
2026-06-17 12:40:04 +00:00
double LotSize = 0.01;
2026-06-16 12:09:10 +00:00
int Slippage = 3;
double StopLossPrice = 0;
double TakeProfitPrice = 0;
bool BuyTradeOpen = false;
bool SellTradeOpen = false;
int MagicNumber = 12345;
bool AutoTradingEnabled = true;
int MaxTrades = 1;
2026-06-17 12:49:01 +00:00
int CurrentTrades = 0;
2026-06-16 12:09:10 +00:00
bool UseStopLoss = true;
bool UseTakeProfit = true;
double RiskPercent = 1.0;
bool DemoMode = true;
bool PrintDebugMessages = true;
2026-06-17 12:40:04 +00:00
int OnInit()
{
Print("SMC_BOS_EA Loaded");
return(INIT_SUCCEEDED);
2026-06-14 11:22:27 +00:00
}
void OnTick()
{
if(IsSwingHigh(2))
Print("Swing High Found");
if(IsSwingLow(2))
Print("Swing Low Found");
2026-06-14 14:17:56 +00:00
if(BuyLiquiditySweep(1))
Print("BUY Liquidity Sweep Found");
if(SellLiquiditySweep(1))
Print("SELL Liquidity Sweep Found");
2026-06-15 11:53:18 +00:00
if(BullishBOS(1))
Print("Bullish BOS Found");
if(BearishBOS(1))
Print("Bearish BOS Found");
2026-06-15 11:56:23 +00:00
if(HigherLow(1))
Print("Higher Low Found");
if(LowerHigh(1))
Print("Lower High Found");
2026-06-15 11:59:15 +00:00
if(BullishTrend())
Print("Bullish Trend Confirmed");
if(BearishTrend())
Print("Bearish Trend Confirmed");
2026-06-16 16:37:29 +00:00
}
2026-06-15 12:03:43 +00:00
2026-06-17 13:05:02 +00:00
if(BuySetup() && !BuyTradeOpen && CurrentTrades < MaxTrades)
2026-06-16 16:37:29 +00:00
{
Print("BUY SETUP READY");
OpenBuy();
}
2026-06-15 12:27:32 +00:00
2026-06-17 13:05:02 +00:00
if(SellSetup() && !SellTradeOpen && CurrentTrades < MaxTrades)
2026-06-16 16:37:29 +00:00
{
Print("SELL SETUP READY");
OpenSell();
2026-06-14 14:17:56 +00:00
}
2026-06-14 11:22:27 +00:00
bool IsSwingHigh(int shift)
{
return High[shift] > High[shift+1] &&
High[shift] > High[shift+2] &&
High[shift] > High[shift-1] &&
High[shift] > High[shift-2];
}
bool IsSwingLow(int shift)
{
return Low[shift] < Low[shift+1] &&
Low[shift] < Low[shift+2] &&
Low[shift] < Low[shift-1] &&
Low[shift] < Low[shift-2];
2026-06-14 11:23:26 +00:00
}
bool BuyLiquiditySweep(int shift)
{
return Low[shift] < Low[shift+1] - 5 * _Point &&
Close[shift] > Low[shift+1];
}
bool SellLiquiditySweep(int shift)
{
return High[shift] > High[shift+1] + 5 * _Point &&
Close[shift] < High[shift+1];
}
2026-06-15 11:53:18 +00:00
bool BullishBOS(int shift)
{
return Close[shift] > High[shift+1];
}
bool BearishBOS(int shift)
{
return Close[shift] < Low[shift+1];
2026-06-15 11:56:23 +00:00
}
bool HigherLow(int shift)
{
return Low[shift] > Low[shift+1];
}
bool LowerHigh(int shift)
{
return High[shift] < High[shift+1];
2026-06-15 11:59:15 +00:00
}
bool BullishTrend()
{
return HigherLow(1) && BullishBOS(1);
}
bool BearishTrend()
{
return LowerHigh(1) && BearishBOS(1);
2026-06-15 12:03:43 +00:00
}
bool BuySetup()
{
2026-06-16 12:12:39 +00:00
return BullishTrend() &&
BuyLiquiditySweep(1) &&
BullishBOS(1);
2026-06-15 12:03:43 +00:00
}
bool SellSetup()
{
2026-06-16 12:12:39 +00:00
return BearishTrend() &&
SellLiquiditySweep(1) &&
BearishBOS(1);
2026-06-15 12:18:03 +00:00
}
2026-06-15 12:28:33 +00:00
void OpenBuy()
{
2026-06-15 12:37:34 +00:00
StopLossPrice = Low[1];
TakeProfitPrice = High[10];
2026-06-15 12:40:19 +00:00
Print("BUY ORDER EXECUTED");
2026-06-16 11:33:16 +00:00
2026-06-17 14:05:46 +00:00
if(trade.Buy(LotSize, _Symbol, 0, StopLossPrice, TakeProfitPrice))
2026-06-17 14:00:30 +00:00
Print("BUY ORDER SENT SUCCESSFULLY");
2026-06-17 14:11:58 +00:00
else
Print("BUY ORDER FAILED");
2026-06-17 13:55:47 +00:00
2026-06-16 11:33:16 +00:00
Print("SL: ", StopLossPrice);
Print("TP: ", TakeProfitPrice);
2026-06-16 11:35:28 +00:00
double EntryPrice = Ask;
2026-06-17 13:30:12 +00:00
Print("BUY ENTRY PRICE: ", EntryPrice);
2026-06-16 16:41:05 +00:00
BuyTradeOpen = true;
2026-06-17 12:52:55 +00:00
2026-06-17 13:26:41 +00:00
SellTradeOpen = false;
2026-06-17 12:52:55 +00:00
CurrentTrades++;
2026-06-17 13:14:37 +00:00
Print("CURRENT TRADES: ", CurrentTrades);
2026-06-15 12:28:33 +00:00
}
void OpenSell()
{
2026-06-15 12:41:37 +00:00
StopLossPrice = High[1];
TakeProfitPrice = Low[10];
2026-06-15 12:28:33 +00:00
Print("SELL ORDER EXECUTED");
2026-06-16 11:33:16 +00:00
2026-06-17 14:05:46 +00:00
if(trade.Sell(LotSize, _Symbol, 0, StopLossPrice, TakeProfitPrice))
2026-06-17 14:00:30 +00:00
Print("SELL ORDER SENT SUCCESSFULLY");
2026-06-17 14:11:58 +00:00
else
Print("SELL ORDER FAILED");
2026-06-17 13:55:47 +00:00
2026-06-16 11:33:16 +00:00
Print("SL: ", StopLossPrice);
Print("TP: ", TakeProfitPrice);
2026-06-16 11:35:28 +00:00
double EntryPrice = Bid;
2026-06-17 13:30:12 +00:00
Print("SELL ENTRY PRICE: ", EntryPrice);
2026-06-16 16:41:05 +00:00
SellTradeOpen = true;
2026-06-17 12:52:55 +00:00
2026-06-17 13:26:41 +00:00
BuyTradeOpen = false;
2026-06-17 12:52:55 +00:00
CurrentTrades++;
2026-06-17 13:14:37 +00:00
Print("CURRENT TRADES: ", CurrentTrades);
2026-06-17 12:45:09 +00:00
}
void ResetBuyTrade()
{
BuyTradeOpen = false;
2026-06-17 13:08:04 +00:00
2026-06-17 13:12:04 +00:00
if(CurrentTrades > 0)
2026-06-17 13:08:04 +00:00
CurrentTrades--;
2026-06-17 13:16:32 +00:00
Print("BUY TRADE RESET");
Print("CURRENT TRADES: ", CurrentTrades);
2026-06-17 12:45:09 +00:00
}
void ResetSellTrade()
{
SellTradeOpen = false;
2026-06-17 13:08:04 +00:00
2026-06-17 13:12:04 +00:00
if(CurrentTrades > 0)
2026-06-17 13:08:04 +00:00
CurrentTrades--;
2026-06-17 13:16:32 +00:00
Print("SELL TRADE RESET");
Print("CURRENT TRADES: ", CurrentTrades);
2026-06-15 11:53:18 +00:00
}