Nmd

专家

工作已完成

执行时间2 天

指定

Hello,

 

I am new to MT4 and have tried to code an EA, it does not appear to work as I have coded it.  I think I have gotten most of it but am missing a few steps.

As this is also a learning experience I want the detailed logic as to how the proposed code is to operate. 

I want an EA to do the following -- the %b indicator, referenced below is defined in the test code attached. 

 

If the Bid price is above the 200 period (close) average

and

the %b indicator is less than 20% for five consecutive time periods

buy the next Bar at Ask (market) (there should only be 1 position taken at a time).

 

If in long position and the %b indicator is greater than 80% (only 1 period needed) then close (sell long) at Bid.

 

//+------------------------------------------------------------------+
//|                                                    ETF #2 %b.mq4 |
//|                                            Copyright © 2011, NMD |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, NMD"
#property link      ""

#include <stdlib.mqh>

//External Parameters
extern int MagicNumber = 123;
extern int MAPeriod = 200;
extern int    Bands_period = 20;
extern double Bands_deviation = 2;

//---- buffers
double PercentBB[];

//Global variables
int BuyTicket;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
if(Bars<200)
   {
   Alert("Not enough bars");
   return;
   }

   int    counted_bars = IndicatorCounted();
//----
   double LB, UB;
   int limit;
   
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars - 1;
      
   for(int i = 0; i < limit; i++){
      LB = iBands(NULL, 0, Bands_period, Bands_deviation, 0, PRICE_CLOSE, MODE_LOWER, i);
      UB = iBands(NULL, 0, Bands_period, Bands_deviation, 0, PRICE_CLOSE, MODE_UPPER, i);

      if(UB-LB>0)
      { 
      PercentBB[i] = (iClose(NULL, 0, i) - LB)/(UB - LB) * 100;
      }
   }
//----

int c=0;
while(PercentBB[i]<10)
{
c++;
if(c==3)
break;
}

  
//Moving Averages
double SlowMA = iMA(NULL,0,MAPeriod,0,0,0,0);

// Buy Order
if(Bid>SlowMA && BuyTicket == 0 && c==3)
// Open buy order
   {
BuyTicket=OrderSend(Symbol(),OP_BUY,.01,Ask,5,0,0,"Buy Order",MagicNumber,0,Green);
   }
   
 //Order Close
 if(PercentBB[i]>80)
 {
 OrderSelect(BuyTicket,SELECT_BY_TICKET);
 }
 
 //Close order
 if(OrderCloseTime() == 0 && BuyTicket > 0)
 {
   double CloseLots = OrderLots();
   double ClosePrice = Bid;
   
   bool Closed = OrderClose(BuyTicket,.01,ClosePrice,5,Red);
 }
      
   
   return(0);
  }
//+------------------------------------------------------------------+

 

反馈

1
开发者 1
等级
(473)
项目
1139
44%
仲裁
51
31% / 33%
逾期
501
44%
空闲
2
开发者 2
等级
(73)
项目
257
53%
仲裁
16
50% / 38%
逾期
83
32%
空闲
3
开发者 3
等级
(41)
项目
124
34%
仲裁
32
13% / 75%
逾期
53
43%
空闲
相似订单
Hello, I am looking for an experienced MQL5 developer to create a professional, reliable, fully customizable Expert Advisor (EA) and trading signal system for MetaTrader 5. 1. Supported Markets The EA must support: Gold (XAUUSD) Silver (XAGUSD) Nasdaq 100 (NAS100/US100) Forex currency pairs Bitcoin (BTCUSD) It must work with MT5 brokers, including Tickmill, where these instruments are available. 2. Two Trading Modes
Hi all I'm looking for a good coder Existing Automated Trading System (Expert Advisor) This EA’s building block is the Bheurekso Pattern (which uses price action) indicators. 1. **Indicator Integration**: The EA should be developed utilizing the Bheurekso pattern indicator. 2. **Sell Signals**: The EA must execute a sell order upon the appearance of any of the following bearish signals or a down arrow that appears
Entry Strategy: Explain exact conditions for opening a trade specific indicators like Moving Averages or RSI, time of day, or price action rules. Exit Strategy: Define when a trade should closeTake Profit, Stop Loss, Trailing Stop, or indicator signals. Daily Trading Rules: Specify daily limits if applicable maximum trades per day, specific trading hours, or maximum daily loss limit. Risk & Position Sizing: Indicate
I want to create my own trading robot that will automatically open and close trades,it's must be operating 24/7 on both the brokers app and the mt5 as well.it must be able to grow small accounts from 10 usd with proper risk management and smart executions.it must operates on the following brokers EXNESS, XM GLOBAL,WELTRADE and DERIV
I’m looking for a **ready-made MT5 scalping EA specifically for Gold (XAUUSD)**. My main requirement is an **HTF scalping strategy**, so I’m looking for an existing robot that is already developed and can be tested before I make the purchase. I would like to test on demo account first, Any available backtest or trading results * Whether I can test it on a demo account * Your price and licensing details I’m
Request for an Existing Automated Trading System (Expert Advisor) I am looking to acquire an existing, fully functional Expert Advisor (EA) that trades Forex CFDs, with the option of trading other CFDs if the strategy supports them safely. Performance objectives Target average net monthly return: 1.5%. A consistent 1.0% monthly return may be considered if the system demonstrates strong risk control and credible
Hi All, I am looking for a bot EA which makes good profit. If any having please share it for TEST. After proper TESTING only I will make the payment, no cheating no fraud. Please do not waste the time also
Allow me to set the daily trading bias manually to BUY or SELL. Check my defined 4H and 1H trend-alignment conditions. Execute entries based on my 15-minute pullback and continuation rules. Trade only between 06:00 and 16:00 Nigeria time, Monday to Friday. Calculate lot size based on my chosen risk percentage and stop-loss distance. Automatically place stop-loss and take-profit orders. Enforce my daily trade limits
hi, I need a quantower script I need a trailing stop at the 20 ema, And a more complicated version would be a breakout of the Asian session and a retest of the 9ema for an entry and a training stop at the 20 ema
Hi, I’m looking for a **ready-made MT5 scalping EA specifically for Gold (XAUUSD)**. My main requirement is an **HTF scalping strategy**, so I’m looking for an existing robot that is already developed and can be tested before I make the purchase. I’m not looking to build one from scratch at this stage. I would like to first test the EA on a **demo account** to see how it performs under live market conditions and

项目信息

预算
25 USD