#include <stdlib.mqh>
#include <stderror.mqh>
extern double grid = 20;
double gridstep = 6;
double multk[25] = {-5,-4,-3,-2,-1,-1,-1,0,1,1,1,2,3,4,5};
int limit = 5;
double lotseq[25] = {1,1,2.8,6,6,12,28.8};
double stepseq[25];
double gridseqbuy[25];
double gridseqsell[25];
double spred;
int LastLock, step;
int StateOld, StateCur;
int sleeppage = 3;
int Magic = 120976;
double CurrentPrice;
bool SetAll, AP;
int LastBuy, LastSell, ProfitOrder;
int initialization() {
StateCur = 0;
StateOld=StateCur;
spred=MarketInfo(Symbol(), MODE_SPREAD)*Point;
RefreshRates();
CurrentPrice = Bid;
OpenOrder (OP_SELL, LotSize(0), Bid, Bid+400*Point, Ask-grid*Point, "", Magic, Red);
OpenOrder (OP_BUY, LotSize(0), Ask, Ask-400*Point, Bid+grid*Point, "", Magic, Green);
step = 1;
setgrid (CurrentPrice);
SetAll = SetOrders (LotSize(1), LotSize(1), LotSize(1), LotSize(1));
SearchLastSellBuy();
LastLock=0;
}
bool first(){
int ordcnt=0;
for (int cnt=OrdersTotal()-1;cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if ((OrderSymbol() == Symbol()) && (OrderTicket() > LastLock) && ((OrderType() == OP_BUY) || (OrderType() == OP_SELL))) {ordcnt++;}
}
if (ordcnt>0) {return(false);}
else {return(true);}
}
double LotSize(int tStep) {
for (int i=0;i<=limit;i++)
double aLots=lotseq[i]+aLots;
aLots++;
double rez = NormalizeDouble((AccountBalance()/aLots/1000)*lotseq[tStep]/4,1);
if (rez < 0.1) {rez = 0.1;}
return(rez);
}
bool setgrid(double startprice){
for(int i=0;i<=((gridstep+1)*2);i++)
{
stepseq[i]=multk[i]*grid;
gridseqsell[i]=startprice+stepseq[i]*Point;
gridseqbuy[i]=startprice+spred+stepseq[i]*Point;
}
return(0);
}
bool allpresent() {
int BuyCnt = 0;
int SellCnt = 0;
int BuyStopCnt = 0;
int BuyLimitCnt = 0;
int SellStopCnt = 0;
int SellLimitCnt = 0;
for (int cnt=OrdersTotal()-1;cnt>=0;cnt--)
{
OrderSelect(Показано первые 50% кода (символов: 2957)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.