PEACE BOT

MQL5 エキスパート

指定

#property version "2.10"
#property description "Chizzy Trend Rider - HFM-ready (hedging/netting safe)"

#include <Trade/Trade.mqh>
CTrade trade;

//================ INPUTS =================//
input double LotSize        = 0.01;     // Fixed lot (used if RiskPercent = 0)
input double RiskPercent    = 0.0;      // Risk % of balance per trade (0 = use LotSize)
input ulong  MagicNumber    = 220026;

input ENUM_TIMEFRAMES TrendTF = PERIOD_H1;
input ENUM_TIMEFRAMES EntryTF = PERIOD_M15;

input int    FastEMA      = 20;
input int    SlowEMA      = 50;
input int    PullbackEMA  = 20;
input int    ATRPeriod    = 14;

input double ATR_SL       = 1.5;
input double RR           = 2.0;
input double MinTrendGap  = 0.30;       // Min EMA gap (x ATR) to call it a trend
input double PullbackTol  = 0.30;       // Pullback tolerance (x stop distance)

input bool   UseBreakEven = true;
input double BE_Trigger_R = 1.0;        // Move SL to entry after this many R

input int    MaxSpread    = 25;         // Points (adjust per symbol on HFM)
input int    StartHour    = 8;          // SERVER time
input int    EndHour      = 18;         // SERVER time
input double MaxDailyLossPercent = 3.0; // Stop trading for the day (0 = off)

//================ GLOBALS =================//
int hFast, hSlow, hPullback, hATR;
datetime LastBar = 0;

//================ INIT =================//
int OnInit()
{
   trade.SetExpertMagicNumber(MagicNumber);
   trade.SetDeviationInPoints(20);
   trade.SetTypeFillingBySymbol(_Symbol);   // important on HFM (IOC/FOK differs by symbol)

   hFast     = iMA(_Symbol, TrendTF, FastEMA, 0, MODE_EMA, PRICE_CLOSE);
   hSlow     = iMA(_Symbol, TrendTF, SlowEMA, 0, MODE_EMA, PRICE_CLOSE);
   hPullback = iMA(_Symbol, EntryTF, PullbackEMA, 0, MODE_EMA, PRICE_CLOSE);
   hATR      = iATR(_Symbol, EntryTF, ATRPeriod);

   if(hFast==INVALID_HANDLE || hSlow==INVALID_HANDLE ||
      hPullback==INVALID_HANDLE || hATR==INVALID_HANDLE)
      return INIT_FAILED;

   return INIT_SUCCEEDED;
}

void OnDeinit(const int reason)
{
   if(hFast!=INVALID_HANDLE)     IndicatorRelease(hFast);
   if(hSlow!=INVALID_HANDLE)     IndicatorRelease(hSlow);
   if(hPullback!=INVALID_HANDLE) IndicatorRelease(hPullback);
   if(hATR!=INVALID_HANDLE)      IndicatorRelease(hATR);
   Comment("");
}

//================ HELPERS =================//
bool NewBar()
{
   datetime t = iTime(_Symbol, EntryTF, 0);
   if(t != LastBar) { LastBar = t; return true; }
   return false;
}

bool SessionOK()
{
   MqlDateTime tm;
   TimeToStruct(TimeCurrent(), tm);
   return (tm.hour >= StartHour && tm.hour < EndHour);
}

double SpreadPts()
{
   return (SymbolInfoDouble(_Symbol,SYMBOL_ASK) -
           SymbolInfoDouble(_Symbol,SYMBOL_BID)) / _Point;
}

bool SpreadOK() { return SpreadPts() <= MaxSpread; }

// Works on both hedging and netting accounts
bool PositionExists()
{
   for(int i=PositionsTotal()-1; i>=0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(ticket==0) continue;
      if(PositionGetString(POSITION_SYMBOL)==_Symbol &&
         PositionGetInteger(POSITION_MAGIC)==(long)MagicNumber)
         return true;
   }
   return false;
}

double DailyPnL()
{
   datetime dayStart = iTime(_Symbol, PERIOD_D1, 0);
   if(!HistorySelect(dayStart, TimeCurrent())) return 0;

   double pnl = 0;
   for(int i=HistoryDealsTotal()-1; i>=0; i--)
   {
      ulong d = HistoryDealGetTicket(i);
      if(HistoryDealGetInteger(d,DEAL_MAGIC)!=(long)MagicNumber) continue;
      if(HistoryDealGetString(d,DEAL_SYMBOL)!=_Symbol) continue;
      pnl += HistoryDealGetDouble(d,DEAL_PROFIT)
           + HistoryDealGetDouble(d,DEAL_SWAP)
           + HistoryDealGetDouble(d,DEAL_COMMISSION);
   }
   return pnl;
}

bool DailyLossOK()
{
   if(MaxDailyLossPercent <= 0) return true;
   double limit = -AccountInfoDouble(ACCOUNT_BALANCE) * MaxDailyLossPercent / 100.0;
   return (DailyPnL() > limit);
}

double NormLot(double lots)
{
   double mn = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   double mx = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
   double st = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
   lots = MathFloor(lots/st)*st;
   lots = MathMax(mn, MathMin(mx, lots));
   return NormalizeDouble(lots, 2);
}

double CalcLots(double stopDistance)
{
   if(RiskPercent <= 0) return NormLot(LotSize);

   double riskMoney = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0;
   double tickVal   = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE);
   double tickSize  = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE);
   if(tickVal<=0 || tickSize<=0 || stopDistance<=0) return NormLot(LotSize);

   double lossPerLot = (stopDistance / tickSize) * tickVal;
   return NormLot(riskMoney / lossPerLot);
}

bool StopsValid(double stopDistance)
{
   double minDist = (double)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL) * _Point;
   double freeze  = (double)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL) * _Point;
   return (stopDistance > MathMax(minDist, freeze));
}

void ManageBreakEven()
{
   if(!UseBreakEven) return;

   for(int i=PositionsTotal()-1; i>=0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(ticket==0) continue;
      if(PositionGetString(POSITION_SYMBOL)!=_Symbol) continue;
      if(PositionGetInteger(POSITION_MAGIC)!=(long)MagicNumber) continue;

      long   type = PositionGetInteger(POSITION_TYPE);
      double open = PositionGetDouble(POSITION_PRICE_OPEN);
      double sl   = PositionGetDouble(POSITION_SL);
      double tp   = PositionGetDouble(POSITION_TP);
      double buf  = SpreadPts() * _Point;

      if(type==POSITION_TYPE_BUY && sl<open)
      {
         double risk = open - sl;
         double bid  = SymbolInfoDouble(_Symbol,SYMBOL_BID);
         if(bid - open >= risk*BE_Trigger_R)
            trade.PositionModify(ticket, NormalizeDouble(open+buf,_Digits), tp);
      }
      else if(type==POSITION_TYPE_SELL && sl>open)
      {
         double risk = sl - open;
         double ask  = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
         if(open - ask >= risk*BE_Trigger_R)
            trade.PositionModify(ticket, NormalizeDouble(open-buf,_Digits), tp);
      }
   }
}

void Dashboard(string trend, string status)
{
   string tf = EnumToString(EntryTF);
   Comment(
      "========================\n",
      " CHIZZY TREND RIDER v2.1\n",
      "========================\n",
      "Symbol: ", _Symbol, "\n",
      "Entry TF: ", tf, "\n\n",
      "Trend: ", trend, "\n",
      "Status: ", status, "\n",
      "Session: ", (SessionOK()?"OPEN":"CLOSED"), "\n\n",
      "Lot: ", DoubleToString(LotSize,2), (RiskPercent>0?" (risk-based)":""), "\n",
      "Spread: ", DoubleToString(SpreadPts(),1), " pts\n\n",
      "Balance: $", DoubleToString(AccountInfoDouble(ACCOUNT_BALANCE),2), "\n",
      "Equity: $",  DoubleToString(AccountInfoDouble(ACCOUNT_EQUITY),2)
   );
}

//================ MAIN =================//
void OnTick()
{
   ManageBreakEven();

   double fast[], slow[], pullback[], atr[];
   ArraySetAsSeries(fast,true);
   ArraySetAsSeries(slow,true);
   ArraySetAsSeries(pullback,true);
   ArraySetAsSeries(atr,true);

   // Closed bars only (shift 1 and 2) -> no repainting
   if(CopyBuffer(hFast,0,1,2,fast)!=2)         return;
   if(CopyBuffer(hSlow,0,1,2,slow)!=2)         return;
   if(CopyBuffer(hPullback,0,1,1,pullback)!=1) return;
   if(CopyBuffer(hATR,0,1,1,atr)!=1)           return;

   double gap = MathAbs(fast[0]-slow[0]);
   bool strong = (gap >= atr[0]*MinTrendGap);

   // Trend: EMAs ordered, separated, and fast EMA sloping the same way
   bool uptrend   = strong && fast[0]>slow[0] && fast[0]>fast[1];
   bool downtrend = strong && fast[0]<slow[0] && fast[0]<fast[1];

   string trend = "SIDEWAYS";
   if(uptrend)   trend = "BUY";
   if(downtrend) trend = "SELL";

   Dashboard(trend, "Watching");

   if(!NewBar())        return;
   if(!SessionOK())     return;
   if(!SpreadOK())      return;
   if(!DailyLossOK())   return;
   if(PositionExists()) return;

   double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);

   double o = iOpen(_Symbol,EntryTF,1);
   double c = iClose(_Symbol,EntryTF,1);
   double h = iHigh(_Symbol,EntryTF,1);
   double l = iLow(_Symbol,EntryTF,1);

   double stop = atr[0]*ATR_SL;
   if(!StopsValid(stop)) return;

   double lots = CalcLots(stop);

   // BUY: wick touched/near EMA, candle closed back above it and bullish
   if(uptrend)
   {
      bool touched = (l <= pullback[0] + stop*PullbackTol);
      if(touched && c > pullback[0] && c > o)
      {
         double sl = NormalizeDouble(ask - stop, _Digits);
         double tp = NormalizeDouble(ask + stop*RR, _Digits);
         if(!trade.Buy(lots,_Symbol,0,sl,tp,"CTR BUY"))
            Print("Buy failed: ", trade.ResultRetcode(), " ", trade.ResultRetcodeDescription());
         return;
      }
   }

   // SELL
   if(downtrend)
   {
      bool touched = (h >= pullback[0] - stop*PullbackTol);
      if(touched && c < pullback[0] && c < o)
      {
         double sl = NormalizeDouble(bid + stop, _Digits);
         double tp = NormalizeDouble(bid - stop*RR, _Digits);
         if(!trade.Sell(lots,_Symbol,0,sl,tp,"CTR SELL"))
            Print("Sell failed: ", trade.ResultRetcode(), " ", trade.ResultRetcodeDescription());
         return;
      }
   }
}

応答済み

1
開発者 1
評価
(263)
プロジェクト
309
76%
仲裁
14
71% / 0%
期限切れ
6
2%
取り込み中
2
開発者 2
評価
(111)
プロジェクト
184
25%
仲裁
25
16% / 76%
期限切れ
16
9%
暇
3
開発者 3
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
パブリッシュした人: 2 codes
4
開発者 4
評価
(9)
プロジェクト
16
19%
仲裁
2
0% / 50%
期限切れ
3
19%
取り込み中
5
開発者 5
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
仕事中
パブリッシュした人: 2 codes
6
開発者 6
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
7
開発者 7
評価
(10)
プロジェクト
12
33%
仲裁
0
期限切れ
2
17%
仕事中
パブリッシュした人: 1 code
8
開発者 8
評価
(2)
プロジェクト
2
0%
仲裁
1
0% / 100%
期限切れ
0
暇
9
開発者 9
評価
(2)
プロジェクト
2
0%
仲裁
0
期限切れ
0
暇
10
開発者 10
評価
(11)
プロジェクト
18
33%
仲裁
0
期限切れ
1
6%
仕事中
11
開発者 11
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
12
開発者 12
評価
(556)
プロジェクト
850
61%
仲裁
33
27% / 45%
期限切れ
24
3%
仕事中
パブリッシュした人: 1 code
13
開発者 13
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
14
開発者 14
評価
(20)
プロジェクト
26
38%
仲裁
3
33% / 67%
期限切れ
3
12%
暇
15
開発者 15
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
類似した注文
​ Indicators: Fast MA (Period 10, Exponential) and Slow MA (Period 50, Exponential). ​ Buy Signal: When Fast MA crosses above Slow MA. ​ Sell Signal: When Fast MA crosses below Slow MA. ​ Risk Management & Parameters: ​Customizable Lot Size (Default: 0.01). ​Stop Loss (SL) and Take Profit (TP) in pips. ​Trailing Stop options. ​Max Spread filter. ​ Platform: MetaTrader 5 (MQL5)
​ Indicators: Fast MA (Period 10, Exponential) and Slow MA (Period 50, Exponential). ​ Buy Signal: When Fast MA crosses above Slow MA. ​ Sell Signal: When Fast MA crosses below Slow MA. ​ Risk Management & Parameters: ​Customizable Lot Size (Default: 0.01). ​Stop Loss (SL) and Take Profit (TP) in pips. ​Trailing Stop options. ​Max Spread filter. ​ Platform: MetaTrader 5 (MQL5)
A robot 30+ USD
Je souhaite trouver un développeur pour réaliser ce travail et effectuer les paiements via cette application. Je m'engage à ne communiquer avec les candidats que par cette application, y compris par messageries tierces, correspondance personnelle ou courriel. Je comprends que toute personne ne respectant pas ces conditions sera interdite de publier des commandes sur la plateforme Freelance
I am looking for an experienced MQL5/MT5 developer to develop a custom Expert Advisor based on a complete technical architecture already prepared by the client. This is not a request to design a trading strategy from scratch . The strategy architecture, entry/exit concepts, filters, risk-management requirements and testing requirements are already documented. The main responsibility will be MQL5 development
EAs 100+ USD
To apply, you must already have your EA running on an active MT5 trading account connected to the market. The account must have genuine trading history that can be independently reviewed and verified. EA Requirements 1. Prop-Firm Compatible Risk Management - The EA must include daily and overall drawdown protection. - Required inputs: "MaxDailyLoss = 5%" "MaxTotalDrawdown = 10%" - Once either limit is
Strategy 40 - 60 USD
yo i have a strategy i would really like to turn into a signal bot basically please this is very technical and serious to me the strategy needs more time 1 time frame and the bot most be 100% accurate
Ready to use bot 100+ USD
seller must provide the following to be considered... i will answer to all who fit this description, and can purchase more than 1 EA... - brief strategy description - overall EA expectancy - 1 week limited trial version, with whatever settings you consider best (can be blocked on demo, i don't really care) - investor password from a reputable broker (if history is available... live / demo, same thing, doesn't really
I want you to develop a professional HFT trading robot for MT5/MQL5 , initially focused on XAUUSD . The robot should be designed for high-speed tick-level trading , analyzing real-time bid/ask movement, spread, tick velocity, momentum, volatility, price acceleration and short-term market microstructure to identify very short-term opportunities. The core strategy should be capable of opening 5–10+ positions in a
can you help me use a Tickblaze Algo NRBO on the NT platform? I have it somewhat set up, but I have other questions about running it & knowing how to operate it in NT. Thank you if anyone have experience in this kindly bib and let do it asap
I need a fully automated custom Expert Advisor for MetaTrader 5 (MQL5). The EA is intended for use on a The5ers $100,000 2-Step prop-firm account. IMPORTANT DELIVERY REQUIREMENT: I must receive the complete editable .mq5 source code as well as the compiled .ex5 file. Compiled-only delivery is NOT acceptable. The EA must be coded specifically for this project and must not copy trades, use external trading signals or

プロジェクト情報

予算
30+ USD

依頼者

出された注文1
裁定取引数0