Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
//+------------------------------------------------------------------+
//| Stepper.mq4 |
//| doshur |
//| www.doshur.com |
//+------------------------------------------------------------------+
#property copyright "doshur"
#property link "www.doshur.com"
extern int TakeProfit = 5;
extern int Range = 20;
extern int Risk = 2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
//----
static bool ToTrade = false;
static bool FirstTrade = true;
double PrevLow = iLow(Symbol(), 0, 1);
double PrevHigh = iHigh(Symbol(), 0, 1);
double PrevRange = (PrevHigh - PrevLow) / Point;
if(NewBar())
{
if(FirstTrade == false)
{
if(PrevRange >= Range)
ToTrade = true;
else
ToTrade = false;
}
else
{
FirstTrade = false;
}
}
if(ToTrade)
{
if(COT(1) < 1)
{
if(Ask > PrevHigh)
OrderSend(Symbol(), OP_BUY, MM(PrevRange, Risk), Ask, 3, PrevLow, Ask + TakeProfit * Point, "Stepper - BUY", 57390, 0, Blue);
}
if(COT(2) < 1)
{
if(Bid < PrevLow)
OrderSend(Symbol(), OP_SELL, MM(PrevRange, Risk), Bid, 3, PrevHigh, Bid - TakeProfit * Point, "Stepper - SELL", 57391, 0, Red);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//---- Check Is New Bar
bool NewBar()
{
static datetime PrevBar;
if(PrevBar < Time[0])
{
PrevBar = Time[0];
return(true);
}
else
{
return(false);
}
return(false);
}
//---- Check Open Trades
int COT(int BS)
{
int Buys = 0, Sells = 0;
for(int cnt_COT = 0; cnt_COT < OrdersTotal(); cnt_COT++)
{
OrderSelect(cnt_COT, SELECT_BY_POS, MODE_TRADES);
if(OrderType() == OP_BUY && OrderSymbol() == Symbol()) Buys++;
if(OrderType() == OP_SELL && OrderSymbol() == Symbol()) Sells++;
}
if(BS == 1) return(Buys);
if(BS == 2) return(Sells);
}
//---- Money Management
double MM(int SL, int RK)
{
double rLots = NormalizeDouble(AccountBalance() / 1000 * RK / SL, 1); // Risk ?% of balance
if(rLots < 0.1) rLots = 0.1;
return(rLots);
}
Had implemented a first run to overcome the issue and some others
Had not tested the code
Pls test and list down other ammendments
please help, i have tried but have not been able to get this EA to work.
maybe i use the wrong mt4 platform or ???i.e. i use fx-open
and /or is there a newer version i can try ?