//+------------------------------------------------------------------+ //| STORM.mq4 | //| Copyright ©, Никонов Денис Викторович | //| | //+------------------------------------------------------------------+ #property copyright "Copyright ©Никонов Денис Викторович, dzedan@list.ru" #define MAGIC 240406 //---- input parameters extern int ExtDepth=2; extern int ExtDeviation=5; extern int ExtBackstep=3; extern double AStopLoss = 150; // Стоп вначале сессии extern double ATakeProfit = 25; // Тейк вначале сессии extern double Lots=2; extern int LotsWayChoice = 7; // Способ выбора рабочего лота: // 0-фиксированный, // 1-процент от депозита extern double DefaultVolume=1; //Объем ордера по умолчанию. Максимальный объем который даст мартингейл = DefaultVolume*2^MartingaleDeep; extern int MartingaleDeep=7; //Маскимальный показатель степени мартингейла. extern int LotsPercent=4; // Процент от депозита extern string Symb="*"; extern int TimeFrame=0; int i,STP,UD,UDP,TF,DG,MN,PNT; string SMB; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int LongStats[16]; int ShortStats[16]; double MaxVolume; double MinVolume; double StartVolume; double LastAccountBalance; double KellyCorrection=1; double TotalWinCounter=1; double TotalLooseCounter=1; int MartingaleType=0; int bbars; int Counter1=0; int Counter2=0; int Result=0; int init() { LastAccountBalance=AccountBalance(); for (int i=0;i<17;i++) { LongStats[i]=2; ShortStats[i]=1; } MinVolume=DefaultVolume; MaxVolume=DefaultVolume*MathPow(2,MartingaleDeep-1); bbars=Bars; if(Symb=="*") SMB=Symbol(); else SMB=Symb; if(TimeFrame==0) TF=Period(); else TF=TimeFrame; DG=MarketInfo(SMB,MODE_DIGITS); MN=MAGIC+TF; PNT=MarketInfo(SMB,MODE_POINT); STP=MarketInfo(SMB,MODE_STOPLEVEL)*PNT; UDP=0; return(0); return(0); } int deinit() { //---- //---- return(0); } //double GetSizeLot() // { // double Lot = Lots; // int cycle; // int prof = 0; // int orders = HistoryTotal(); // history orders total // int losses = 0; // number of losses orders without a break // int vinn = 0; // int i = orders; // if (LotsWayChoice==0) Lot=Lots; // фиксированный процент от депозита // if (LotsWayChoice==1) { // Lot=MathCeil(AccountFreeMargin()/10000*LotsPercent)/10; // } // return(Lot); // } //+------------------------------------------------------------------+ //| фуккция инициализации эксперта ||||||||||||||||||||||||||||||||||| //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| фуккция деинициализации эксперта ||||||||||||||||||||||||||||||||| //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| основная функция ||||||||||||||||||||||||||||||||||||||||||||||||| //+------------------------------------------------------------------+ int start() { double zc,zp,zcn,zpn,CO,PR; bool f; //---- int buff,LastResult; double P,Q,A,B; if ((bbars!=Bars)&&(Time[0]-TimeCurrent()==0)) { //OrderSelect(0,SELECT_BY_POS,MODE_TRADES); // OrderClose(OrderTicket(),OrderLots(),Bid,20); //OrderClose(OrderTicket(),OrderLots(),Ask,20); Counter2++; bbars=Bars; if (AccountBalance()>LastAccountBalance) TotalWinCounter++; if (AccountBalance()LastAccountBalance) { DefaultVolume=DefaultVolume*2; } } if (MartingaleType ==1) { if (Counter1==1) DefaultVolume=MaxVolume; if (AccountBalance()>LastAccountBalance) { DefaultVolume=DefaultVolume/2; } } if (MartingaleType ==2) { if (Counter1==1) DefaultVolume=MinVolume; if (AccountBalance()LastAccountBalance) { DefaultVolume=DefaultVolume*2; } if (AccountBalance()LastAccountBalance) { DefaultVolume=DefaultVolume/2; } if (AccountBalance()0) { buff=LastResult+8; LongStats[buff]++; } if ((Close[1]-Open[1])<0) { buff=LastResult+8; ShortStats[buff]++; } LastAccountBalance=AccountBalance(); if ((MartingaleType==7)&&(Counter1==MartingaleDeep)) MartingaleType=0; if (Counter1==MartingaleDeep) { MartingaleType++; Counter1=0; } Counter1++; } for(f=true,i=2;i0) { if(f) { f=false; zc=zp; } else break; } } if(zpzc) { UD=OP_SELLLIMIT; PR=NormalizeDouble((zp-zc)/10,DG); CO=NormalizeDouble((zp+zc)/2.0-PR,DG); } else return(0); if(PR<10*PNT) return(0); for(i=0;i0) { if(f) { f=false; zcn=zpn; } else break; } } if(zpn<=0) {zcn=zc; zpn=zp;} if(UD==OP_SELLLIMIT && UDP!=OP_SELLLIMIT && zcnCO) { if(MarketInfo(SMB,MODE_BID)-CO