Price Data Components
Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
undular_v1.3
//+------------------------------------------------------------------+
//| undular.mq4 |
//| Cemen4yk |
//| https://vk.com/cemen4yk |
//+------------------------------------------------------------------+
#property copyright "Cemen4yk"
#property link "https://vk.com/cemen4yk"
#property version "1.3"
#property strict
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
enum mode1
{
SMA = MODE_SMA,
EMA = MODE_EMA,
SMMA = MODE_SMMA,
LWMA = MODE_LWMA
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
enum mode2
{
PRICECLOSE = PRICE_CLOSE,
PRICEOPEN = PRICE_OPEN,
PRICEHIGH = PRICE_HIGH,
PRICELOW = PRICE_LOW,
PRICEMEDIAN = PRICE_MEDIAN,
PRICETYPICAL = PRICE_TYPICAL,
PRICEWEIGHTED = PRICE_WEIGHTED
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
enum mode3
{
CLOSE = 1,
HIGH_LOW = 0
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
enum mode4
{
Lock_OFF = 0,
Lock_ON = 1
};
extern string undular="EA settings"; // EA settings
extern double lotnom = 0.001; // lots on 1000$
extern double Profit = 0.3; // profit on $ 0.01 lot
extern double lotstep = 1.5; // martingale exponent
extern double lotper = 3; // lock exponent
extern int Step2 = 5; // second orders step (0-off)
extern int Step3 = 15; // step martingale(0-off)
input mode4 mode_Lock = 1; // lock (on/off)
extern int slippage = 9; // slippage
extern int magic = 1111; // OrderMagicNumber
extern string Indik="indicators settings"; // indicators settings
extern int Step5 = 50; // stohastic level Í4 (<) buy
extern int Step6 = 50; // stohastic level Í4 (>) sell
extern int per1 = 5; // period primary stochastic 1 240 min
extern int per1s = 3; // slowing primary stochastic 1 240 min
extern int per5 = 7; // period primary stochastic 2 240 min
extern int per5s = 5; // slowing primary stochastic 2 240 min
extern int per3 = 20; // period stochastic 3 240 min
extern int per3s = 5; // slowing stochastic 3 240 min
extern int per2 = 20; // period stochastic 4 60 min
extern int per2s = 5; // slowing stochastic 4 60 min
extern int per4 = 20; // period stochastic 5 30 min
extern int per4s = 10; // slowing stochastic 5 30 min
input mode3 mode_STOH = 1; // prices stochastic
extern int per6 = 70; // period ma 240 min
input mode1 mode_MA = 3; // ma method
input mode2 modePrise = 0; // prices ma
int ticket;
int Mas_Tip[13];
int Magik;
double lotsize,One_Lot,lotnew,lotmin;
double profit,profit2;
int Step4=mode_Lock;
int modeMA=mode_MA;
int modeprise= modePrise;
int modeSTOH = mode_STOH;
int a,b,K;
double money=0;
datetime TimeENDwork=D'30.06.2099';
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
Terminal(0);
if(5==Period()){a=15; b=5;}
if(15==Period()){a=7; b=3;}
if(60==Period()){a=25; b=15;}
if(240==Period()){a=30; b=20;}
if(1440==Period()){a=35; b=25;}
if(Digits==3 || Digits==5)
{
slippage *= 10;
Step2 *= 10;
Step3 *= 10;
a *= 10;
b *= 10;
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
if(TimeCurrent()<TimeENDwork)
{
One_Lot=MarketInfo(Symbol(),MODE_MARGINREQUIRED);
Magik=(magic+Mas_Tip[11]);
Terminal(Magik);
lotsize=NormalizeDouble(lotnom*AccountBalance()/1000,2);
if(lotsize <= 0.01) lotsize = 0.01;
if(lotsize >= 999) lotsize = 999;
if((iBars(Symbol(),0)>1) && (iBars(Symbol(),10080)>3) && (iBars(Symbol(),1440)>10) && (iBars(Symbol(),240)>42) && (iBars(Symbol(),30)>per4) && (iBars(Symbol(),60)>per2) && (iBars(Symbol(),240)>per6))
{
if(AccountFreeMargin()>(One_Lot/100))
{
money=AccountFreeMargin();
}
else Comment("Not enough money");
if(lotsize < MarketInfo(Symbol(),MODE_MINLOT)){lotsize = MarketInfo(Symbol(),MODE_MINLOT);}
if(lotsize > MarketInfo(Symbol(),MODE_MAXLOT)){lotsize = MarketInfo(Symbol(),MODE_MAXLOT);}
lotmin=MarketInfo(Symbol(),MODE_MINLOT);
//-----------------------------------------------------------------------
bool STOH10=False,STOH13=False,STOH12=False,STOH11=False,CCIS=False,CCIB=False,STOH=False,STOH1=False,STOH2=False,STOH3=False,STOHB=False,STOHS=False,MAS=false,MAB=false,STOHMB=false,STOHMS=false,STOH1S=false,STOH1B=false,STOH4=false,STOH5=false,STOH6=false,STOH7=false,STOH8=false,STOH9=false,HIGH=false;
bool MA00=false,MA111=false,MA1=false,MA11=false,MA0=false,MA2=false,MA3=false,MA4=false,MA5=false,MA6=false,MA7=false,MA8=false,MA9=false,MA10=false;
ticket=0;
//óñëîâèÿ íà ñåëë
if((iStochastic(NULL,240,per5,1,per5s,MODE_SMA,modeSTOH,MODE_MAIN,0)<=5) || ((iStochastic(NULL,240,per5,1,per5s,MODE_SMA,modeSTOH,MODE_MAIN,0)+2)<iStochastic(NULL,240,per5,1,per5s,MODE_SMA,modeSTOH,MODE_MAIN,1)))
{
STOH12=true;
}
else STOH12=false;
//----------------------------------------------------------------------
if((iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,0))>Step6)
{
STOH10=true;
}
else STOH10=false;
//----------------------------------------------------------------------
if((iStochastic(NULL,30,per4,1,per4s,MODE_SMA,modeSTOH,MODE_MAIN,0)<=5) || ((iStochastic(NULL,30,per4,1,per4s,MODE_SMA,modeSTOH,MODE_MAIN,0))<iStochastic(NULL,30,per4,1,per4s,MODE_SMA,modeSTOH,MODE_MAIN,1)))
{
STOH8=true;
}
else STOH8=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,0)<=5) || ((iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,0)+5)<iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,1)))
{
STOH6=true;
}
else STOH6=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,240,per3,1,per3s,MODE_SMA,modeSTOH,MODE_MAIN,0)<=5) || ((iStochastic(NULL,240,per3,1,per3s,MODE_SMA,modeSTOH,MODE_MAIN,0))<iStochastic(NULL,240,per3,1,per3s,MODE_SMA,modeSTOH,MODE_MAIN,1)))
{
STOH4=true;
}
else STOH4=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,0)<=5) || ((iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,0)+2)<iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,1)))
{
STOH=true;
}
else STOH=false;
//-----------------------------------------------------------------------
if(iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,0)>Step6)
{
STOHS=true;
}
else STOHS=false;
//-----------------------------------------------------------------------
//óñëîâèÿ íà áàé
if((iStochastic(NULL,240,per5,1,per5s,MODE_SMA,modeSTOH,MODE_MAIN,0)>=95) || (iStochastic(NULL,240,per5,1,per5s,MODE_SMA,modeSTOH,MODE_MAIN,0)>(iStochastic(NULL,240,per5,1,per5s,MODE_SMA,modeSTOH,MODE_MAIN,1)+2)))
{
STOH13=true;
}
else STOH13=false;
//-----------------------------------------------------------------------
if(iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,0)<Step5)
{
STOH11=true;
}
else STOH11=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,30,per4,1,per4s,MODE_SMA,modeSTOH,MODE_MAIN,0)>=95) || (iStochastic(NULL,30,per4,1,per4s,MODE_SMA,modeSTOH,MODE_MAIN,0)>(iStochastic(NULL,30,per4,1,per4s,MODE_SMA,modeSTOH,MODE_MAIN,1))))
{
STOH9=true;
}
else STOH9=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,0)>=95) || (iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,0)>(iStochastic(NULL,240,per1,1,per1s,MODE_SMA,modeSTOH,MODE_MAIN,1)+5)))
{
STOH7=true;
}
else STOH7=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,240,per3,1,per3s,MODE_SMA,modeSTOH,MODE_MAIN,0)>=95) || (iStochastic(NULL,240,per3,1,per3s,MODE_SMA,modeSTOH,MODE_MAIN,0)>(iStochastic(NULL,240,per3,1,per3s,MODE_SMA,modeSTOH,MODE_MAIN,1))))
{
STOH5=true;
}
else STOH5=false;
//-----------------------------------------------------------------------
if((iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,0)>=95) || ((iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,0)>iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,1)+2)))
{
STOH1=true;
}
else STOH1=false;
//-----------------------------------------------------------------------
if(iStochastic(NULL,60,per2,1,per2s,MODE_SMA,modeSTOH,MODE_MAIN,0)<Step5)
{
STOHB=true;
}
else STOHB=false;
//-----------------------------------------------------------------------
if(iMA(NULL,240,per6,0,modeMA,modeprise,1)>iMA(NULL,240,per6,0,modeMA,modeprise,2))
{
MA00=true;
}
else MA00=false;
//-----------------------------------------------------------------------
if(iMA(NULL,240,per6,0,modeMA,modeprise,1)<iMA(NULL,240,per6,0,modeMA,modeprise,2))
{
MA111=true;
}
else MA111=false;
//-----------------------------------------------------------------------
if(iMA(NULL,240,per1,0,modeMA,modeprise,0)>(iMA(NULL,240,per1,0,modeMA,modeprise,1)))
{
MA1=true;
}
else MA1=false;
//-----------------------------------------------------------------------
if(iMA(NULL,240,per1,0,modeMA,modeprise,0)<(iMA(NULL,240,per1,0,modeMA,modeprise,1)))
{
MA2=true;
}
else MA2=false;
//-----------------------------------------------------------------------
if(iMA(NULL,60,per1,0,modeMA,modeprise,0)>(iMA(NULL,60,per1,0,modeMA,modeprise,1)))
{
MA3=true;
}
else MA3=false;
//-----------------------------------------------------------------------
if(iMA(NULL,60,per1,0,modeMA,modeprise,0)<(iMA(NULL,60,per1,0,modeMA,modeprise,1)))
{
MA4=true;
}
else MA4=false;
//------------------------------èíôà íà ýêðàí--------------------------------------------------------------------
Comment(
"\n"," Account: - ¹: ",AccountNumber(),
"\n"," TimeENDwork: - : ",TimeENDwork,
"\n"," TimeCurrent: - : ",TimeCurrent(),
"\n"," AccountCompany ",AccountCompany(),
"\n"," AccountLeverage = 1 : ",AccountLeverage(),"\n",
"-----------------------------------------------------------",
"\n"," AccountBalance = ",NormalizeDouble(AccountBalance(),2),
"\n"," AccountMargin = ",NormalizeDouble(AccountMargin(),2),
"\n"," AccountEquity = ",NormalizeDouble(AccountEquity(),2),"\n",
"-----------------------------------------------------------",
"\n"," Orders for buy = ",Mas_Tip[8],
"\n"," Orders for sell = ",Mas_Tip[9],"\n",
"-----------------------------------------------------------",
"\n"," Lots for buy = ",NormalizeDouble(findlotsumm(OP_BUY,0,""),2),
"\n"," Lots for sell = ",NormalizeDouble(findlotsumm(OP_SELL,0,""),2),
"\n"," Magic = ",Magik,"\n",
"-----------------------------------------------------------",
"\n"
);
//-----------------------------------------------------------------------
profit=Profit*100*(NormalizeDouble((findlotsumm(OP_SELL,0,"")+findlotsumm(OP_SELL,0,"")),2));
profit2=Profit*100*(NormalizeDouble((findlotsumm(OP_SELL,0,"ALL")+findlotsumm(OP_SELL,0,"ALL")),2));
//----------------------------------------------------------------------
if((STOH==false)&&(MA4==false)&&(STOH6==false)&&(((ordersprofit(0,OP_SELL,"ALL")) >= profit))){Close_Delete(OP_SELL,0,"ALL");}
if((STOH1==false)&&(MA3==false)&&(STOH7==false)&&(((ordersprofit(0,OP_BUY,"ALL")) >= profit))){Close_Delete(OP_BUY,0,"ALL");}
//-----------------------------------------------------------------------
if((STOH==false)&&(STOH4==false)&&(STOH6==false)&&(((ordersprofit(0,OP_SELL,"ALL")) >= profit))){Close_Delete(OP_SELL,0,"ALL");}
if((STOH1==false)&&(STOH5==false)&&(STOH7==false)&&(((ordersprofit(0,OP_BUY,"ALL")) >= profit))){Close_Delete(OP_BUY,0,"ALL");}
//-----------------------------------------------------------------------
if((Mas_Tip[11]>=1))
{
if((ordersprofit(0,OP_SELL,"ALL")+ordersprofit(0,OP_BUY,"ALL"))>=profit)
{
Close_Delete(OP_BUY,0,"ALL");
Close_Delete(OP_SELL,0,"ALL");
}
}
//----------------------------------------------------------------
if((Mas_Tip[12]>=1) && (Mas_Tip[11]==0))
{
if((ordersprofit(0,OP_BUY,"KILL")+(ordersprofit(0,OP_SELL,"KILL"))>=profit2))
{
Close_Delete(OP_BUY,0,"KILL");
Close_Delete(OP_SELL,0,"KILL");
}
}
//--------------------------------ìîäóëü áàåâ---------------------------------------------------------------------
if((STOH11==true) && (STOHB==true) && (STOH1==true) && (STOH5==true) && (STOH9==true) && (STOH13==true) && (STOH7==true) && (MA00==true) && (MA3==true))
{
if((Mas_Tip[0]>=1) && (Mas_Tip[2]>=1) && (Step2!=0) && (ticket==0) && (Bid>=(findlastprise(OP_BUY,Magik)+Step2*Point)))
{
if(money>(One_Lot*lotsize))
{
ticket=OrderSend(Symbol(),OP_BUY,lotsize,Ask,slippage,0,0,"Buy_2",Magik,0,clrLime);
if(ticket>0){Print("Second order buy");}
}
}
}
if((STOH4==false) && (STOH6==false) && (STOH12==false) && (STOH5==true) && (STOH13==true) && (STOH7==true) && (MA3==true))
{
if((Mas_Tip[1]==0) && (Mas_Tip[0]==0) && ((Mas_Tip[11]==0) && (ticket==0)))
{
if(money>(One_Lot*lotsize))
{
ticket=OrderSend(Symbol(),OP_BUY,lotsize,Ask,slippage,0,0,"Buy_1",Magik,0,clrGreen);
if(ticket>0)
{
Print("First order buy");
ObjectCreate((string)ticket,OBJ_ARROW_UP,0,Time[0],iLow(NULL,240,0)-b*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrGreen);
}
}
}
}
if((STOH4==false) && (STOH6==false) && (STOH12==false) && (STOH5==true) && (STOH13==true) && (STOH7==true) && (MA00==true) && (MA3==true))
{
if(((Mas_Tip[8]>=1) || (Mas_Tip[9]>=1)) && (Mas_Tip[11]>=1) && (Mas_Tip[0]==0) && (ticket==0))
{
lotnew=NormalizeDouble(((findlotsumm(OP_BUY,0,"")+(findlotsumm(OP_SELL,0,"")))/(Mas_Tip[8]+Mas_Tip[9])),2)*lotper;
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_BUY,lotnew,Ask,slippage,0,0,"Buy_1",Magik,0,clrForestGreen);
if(ticket>0)
{
Print("First order buy + exponent");
ObjectCreate((string)ticket,OBJ_ARROW_UP,0,Time[0],iLow(NULL,240,0)-b*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrForestGreen);
}
}
}
}
if((STOH7==true) && (MA00==true) && (MA1==true) && (MA3==true))
{
if((Mas_Tip[0]>=1) && (Step3!=0) && (ticket==0) && (Ask<=(findminprise(OP_BUY,Magik)-Step3*Point)))
{
lotnew=NormalizeDouble(findlastlot(OP_BUY,Magik)*lotstep,2);
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_BUY,lotnew,Ask,slippage,0,0,"Buy_3",Magik,0,clrDarkGreen);
if(ticket>0)
{
Print("Order buy + exponent");
ObjectCreate((string)ticket,OBJ_ARROW_UP,0,Time[0],iLow(NULL,240,0)-b*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrDarkGreen);
}
}
}
}
if((STOH7==true) && (MA111==true) && (MA1==true) && (MA3==true))
{
if((Mas_Tip[0]>=1) && (Step3!=0) && (ticket==0) && (Ask<=(findminprise(OP_BUY,Magik)-Step3*Point)))
{
lotnew=NormalizeDouble(findlastlot(OP_BUY,Magik),2);
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_BUY,lotnew,Ask,slippage,0,0,"Buy_3",Magik,0,clrLimeGreen);
if(ticket>0)
{
Print("Order buy new");
ObjectCreate((string)ticket,OBJ_ARROW_UP,0,Time[0],iLow(NULL,240,0)-b*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrLimeGreen);
}
}
}
}
//-----------------------------------ëîê áàåâ----------------------------------------
/* if((STOH1==false)&&(STOH5==false)&&(STOH7==false)&&(STOH==true)&&(STOH4==true)&&(STOH6==true)&&(STOH12==true)&&(MA00==true)&&((ordersprofit(0,OP_BUY,"ALL")) < 0)){
if ((Mas_Tip[0] >= 1)&&(Mas_Tip[2] >= 1)&&(Mas_Tip[5] == 0)&&(ticket == 0)&&(Step4 != 0)&&(findlotsumm(OP_BUY,0,"")>findlotsumm(OP_SELL,0,""))){
lotnew = NormalizeDouble(((findlotsumm(OP_BUY,0,"")-findlotsumm(OP_SELL,0,""))),2);
if(money>(One_Lot*lotnew)&&(lotnew >= lotmin)){
ticket = OrderSend(Symbol(), OP_SELL,lotnew, Bid, slippage, 0, 0,"Lok_sell", Magik, 0 ,clrYellow);
if (ticket >0){Print("Lock buy");
ObjectCreate((string)ticket,OBJ_ARROW_DOWN,0,Time[0],iHigh(NULL,240,0)+a*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrYellow);}}}
}*/
if((STOH1==false) && (STOH5==false) && (STOH7==false) && (STOH==true) && (STOH4==true) && (STOH6==true) && (STOH12==true) && (MA111==true) && (MA2==true) && (MA4==true) && ((ordersprofit(0,OP_BUY,"ALL"))<0))
{
if((Mas_Tip[0]>=1) && (Mas_Tip[2]>=1) && (Mas_Tip[5]==0) && (ticket==0) && (Step4!=0) && (findlotsumm(OP_BUY,0,"")>findlotsumm(OP_SELL,0,"")))
{
lotnew=NormalizeDouble(((findlotsumm(OP_BUY,0,"")-findlotsumm(OP_SELL,0,""))),2)*lotper;
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_SELL,lotnew,Bid,slippage,0,0,"Lok_sell",Magik,0,clrOrange);
if(ticket>0)
{
Print("Lock buy + exponent");
ObjectCreate((string)ticket,OBJ_ARROW_DOWN,0,Time[0],iHigh(NULL,240,0)+a*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrOrange);
}
}
}
}
//-----------------------------------ëîê ñåëîâ----------------------------------------
/*if((STOH==false)&&(STOH4==false)&&(STOH6==false)&&(STOH1==true)&&(STOH5==true)&&(STOH7==true)&&(STOH13==true)&&(MA111==true)&&((ordersprofit(0,OP_SELL,"ALL")) < 0)){
if ((Mas_Tip[1] >= 1)&&(Mas_Tip[5] >= 1)&&(Mas_Tip[2] == 0)&&(ticket == 0)&&(Step4 != 0)&&(findlotsumm(OP_SELL,0,"")>findlotsumm(OP_BUY,0,""))){
lotnew = NormalizeDouble(((findlotsumm(OP_SELL,0,"")-findlotsumm(OP_BUY,0,""))),2);
if(AccountFreeMargin()>(One_Lot*lotnew)&&(lotnew >= lotmin)){
ticket = OrderSend(Symbol(), OP_BUY,lotnew, Ask, slippage,0, 0,"Lok_buy", Magik, 0,clrBlue);
if (ticket >0){Print("Lock sell");
ObjectCreate((string)ticket,OBJ_ARROW_UP,0,Time[0],iLow(NULL,240,0)-b*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrBlue);}}}
}*/
if((STOH==false) && (STOH4==false) && (STOH6==false) && (STOH1==true) && (STOH5==true) && (STOH7==true) && (STOH13==true) && (MA00==true) && (MA1==true) && (MA3==true) && ((ordersprofit(0,OP_SELL,"ALL"))<0))
{
if((Mas_Tip[1]>=1) && (Mas_Tip[5]>=1) && (Mas_Tip[2]==0) && (ticket==0) && (Step4!=0) && (findlotsumm(OP_SELL,0,"")>findlotsumm(OP_BUY,0,"")))
{
lotnew=NormalizeDouble(((findlotsumm(OP_SELL,0,"")-findlotsumm(OP_BUY,0,"")))*lotper,2);
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_BUY,lotnew,Ask,slippage,0,0,"Lok_buy",Magik,0,clrDarkBlue);
if(ticket>0)
{
Print("Lock sell + exponent");
ObjectCreate((string)ticket,OBJ_ARROW_UP,0,Time[0],iLow(NULL,240,0)-b*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrDarkBlue);
}
}
}
}
//-----------------------------------ìîäóëü ñåëîâ--------------------------------------
if((STOH10==true) && (STOHS==true) && (STOH==true) && (STOH4==true) && (STOH8==true) && (STOH6==true) && (STOH12==true) && (MA111==true) && (MA4==true))
{
if((Mas_Tip[1]>=1) && (Mas_Tip[5]>=1) && (ticket==0) && (Step2!=0) && (Ask<=(findlastprise(OP_SELL,Magik)-Step2*Point)))
{
if(money>(One_Lot*lotsize))
{
ticket=OrderSend(Symbol(),OP_SELL,lotsize,Bid,slippage,0,0,"Sell_2",Magik,0,clrCrimson);
if(ticket>0){Print("Second order sell");}
}
}
}
if((STOH5==false) && (STOH13==false) && (STOH7==false) && (STOH4==true) && (STOH6==true) && (STOH12==true) && (MA4==true))
{
if((Mas_Tip[1]==0) && (Mas_Tip[0]==0) && ((Mas_Tip[11]==0) && (ticket==0)))
{
if(money>(One_Lot*lotsize))
{
ticket=OrderSend(Symbol(),OP_SELL,lotsize,Bid,slippage,0,0,"Sell_1",Magik,0,clrRed);
if(ticket>0)
{
Print("First order sell");
ObjectCreate((string)ticket,OBJ_ARROW_DOWN,0,Time[0],iHigh(NULL,240,0)+a*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrRed);
}
}
}
}
if((STOH5==false) && (STOH13==false) && (STOH7==false) && (STOH4==true) && (STOH6==true) && (STOH12==true) && (MA111==true) && (MA4==true))
{
if(((Mas_Tip[8]>=1) || (Mas_Tip[9]>=1)) && (Mas_Tip[11]>=1) && (ticket==0) && (Mas_Tip[1]==0))
{
lotnew=NormalizeDouble(((findlotsumm(OP_BUY,0,"")+(findlotsumm(OP_SELL,0,"")))/(Mas_Tip[8]+Mas_Tip[9])),2)*lotper;
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_SELL,lotnew,Bid,slippage,0,0,"Sell_1",Magik,0,clrOrangeRed);
if(ticket>0)
{
Print("First order sell + exponent");
ObjectCreate((string)ticket,OBJ_ARROW_DOWN,0,Time[0],iHigh(NULL,240,0)+a*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrOrangeRed);
}
}
}
}
if((STOH6==true) && (MA111==true) && (MA4==true) && (MA2==true))
{
if((Mas_Tip[1]>=1) && (Step3!=0) && (ticket==0) && (Bid>=(findmaxprise(OP_SELL,Magik)+Step3*Point)))
{
lotnew=NormalizeDouble(findlastlot(OP_SELL,Magik)*lotstep,2);
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_SELL,lotnew,Bid,slippage,0,0,"Sell_3",Magik,0,clrMaroon);
if(ticket>0)
{
Print("Order sell + exponent");
ObjectCreate((string)ticket,OBJ_ARROW_DOWN,0,Time[0],iHigh(NULL,240,0)+a*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrMaroon);
}
}
}
}
if((STOH6==true) && (MA00==true) && (MA4==true) && (MA2==true))
{
if((Mas_Tip[1]>=1) && (Step3!=0) && (ticket==0) && (Bid>=(findmaxprise(OP_SELL,Magik)+Step3*Point)))
{
lotnew=NormalizeDouble(findlastlot(OP_SELL,Magik),2);
if(money>(One_Lot*lotnew) && (lotnew>=lotmin))
{
ticket=OrderSend(Symbol(),OP_SELL,lotnew,Bid,slippage,0,0,"Sell_3",Magik,0,clrFireBrick);
if(ticket>0)
{
Print("Order sell new");
ObjectCreate((string)ticket,OBJ_ARROW_DOWN,0,Time[0],iHigh(NULL,240,0)+a*Point);
ObjectSet((string)ticket,OBJPROP_COLOR,clrFireBrick);
}
}
}
}
//-----------------------------------------------------------------------
lotsize=lotnom;
}
else Comment("Not enough history");
}
else Comment("Time is out");
}
//------------------------------ìàññèâ îðäåðîâ---------------------------------
int Terminal(int magik)
{
ArrayInitialize(Mas_Tip,0);
for(int i=0; i<OrdersTotal(); i++)
{
if((OrderSelect(i,SELECT_BY_POS)==true))
{
if(OrderSymbol()==Symbol())
{
if(OrderMagicNumber()==magik || magik==0)
{
if(OrderType() == OP_BUY) Mas_Tip[0]++;
if(OrderType() == OP_SELL) Mas_Tip[1]++;
if(OrderComment() == "Buy_1") Mas_Tip[2]++;
if(OrderComment() == "Sell_1") Mas_Tip[5]++;
if((OrderComment()=="Lok_buy") || (OrderComment()=="Lok_sell")) Mas_Tip[10]++;
}
if((OrderComment()== "Lok_buy")||(OrderComment() == "Lok_sell")) Mas_Tip[11]++;
if(OrderType() == OP_BUY) Mas_Tip[8]++;
if(OrderType() == OP_SELL) Mas_Tip[9]++;
if(OrderComment() == "Sell_3") Mas_Tip[7]++;
if(OrderComment() == "Buy_3") Mas_Tip[4]++;
if(OrderComment() == "Sell_2") Mas_Tip[6]++;
if(OrderComment() == "Buy_2") Mas_Tip[3]++;
}
if((OrderComment()=="Lok_sell") || (OrderComment()=="Lok_buy")) Mas_Tip[12]++;
}
}
return(0);
}
//-----------------------------Çàêðûòèå/óäàëåíèå îðäåðîâ-----------------------------
void Close_Delete(int otype,int magik,string comment)
{
bool res=false;
int i,totalC=OrdersTotal();
for(i=totalC; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS) && (OrderSymbol()==Symbol() || comment=="KILL"))
{
if((OrderComment()==comment || comment=="ALL" || comment=="KILL") && (OrderMagicNumber()==magik || magik==0) && OrderType()==otype)
{
res=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,clrNONE);
if(res==true){Print("OrderClose Ticket ",OrderTicket());}
}
}
}
}
//+----------------ïîèñê ìèí öåíû îðäåðà----------------------------------------+
double findminprise(int otype,int magik)
{
double oldopenprise=0;
double prise=9999;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magik && OrderType()==otype)
oldopenprise=OrderOpenPrice();
if(oldopenprise<prise)
prise=OrderOpenPrice();
}
}
return(prise);
}
//+----------------ïîèñê ìàêñ öåíû îðäåðà----------------------------------------+
double findmaxprise(int otype,int magik)
{
double oldopenprise=0;
double prise=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magik && OrderType()==otype)
oldopenprise=OrderOpenPrice();
if(oldopenprise>prise)
prise=OrderOpenPrice();
}
}
return(prise);
}
//+----------------ïîèñê ñóììàðíîãî îáü¸ìà îðäåðîâ----------------------------+
double findlotsumm(int otype,int magik,string symbol)
{
double oldlot=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if((OrderSymbol()==Symbol() || symbol=="ALL") && (OrderMagicNumber()==magik || magik==0) && OrderType()==otype)
oldlot+=OrderLots();
}
}
return(oldlot);
}
//+----------------ïîèñê ïîñëåäíåãî îáü¸ìà îðäåðà----------------------------+
double findlastlot(int otype,int magik)
{
int oldticket=0;
double oldlot=0;
ticket=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(((OrderComment()!="Lok_buy") || (OrderComment()!="Lok_sell")) && OrderSymbol()==Symbol() && OrderMagicNumber()==magik && OrderType()==otype)
oldticket=OrderTicket();
if(oldticket>ticket)
oldlot = OrderLots();
ticket = oldticket;
}
}
return(oldlot);
}
//+----------------ðàñ÷¸ò ïðîôèòà â âàëþòå----------------------------+
double ordersprofit(int magik,int otype,string comment)
{
double profit_=0;
{
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if((OrderComment()==comment || comment=="ALL" || comment=="KILL") && (OrderSymbol()==Symbol() || comment=="KILL") && (OrderMagicNumber()==magik || magik==0) && OrderType()==otype)
profit_+=OrderProfit()+OrderSwap()+OrderCommission();
}
}
}
return(profit_);
}
//+----------------ïîèñê ïîñëåäíåé öåíû îðäåðà----------------------------------------+
double findlastprise(int otype,int magik)
{
int oldticket=0;
double oldopenprise=0;
ticket=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magik && OrderType()==otype)
oldticket=OrderTicket();
if(oldticket>ticket)
oldopenprise=OrderOpenPrice();
ticket=oldticket;
}
}
return(oldopenprise);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---