Mam kod:
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| Poziom i spadek.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
void OnTick()
{
string morning="";
if (Hour()>6 && Minute()>5)
{
morning="buy";
}
string evening="";
if (Hour()<9)
{
evening="buy";
}
string trade="";
int Orders=OrdersTotal();
if (Orders==0)
{
trade="buy";
}
string spadek="";
if (Close[1]>Open[1])
{
spadek="buy";
}
double one=2;
double two=1;
double three=0;
double four=-1;
double five=-2;
one=one*Close[2];
two=two*Close[3];
three=three*Close[4];
four=four*Close[5];
five=five*Close[6];
double counter_b;
counter_b=one+two+three+four+five;
double denominator_b;
denominator_b= 10;
double b;
b=counter_b/denominator_b;
double counter_a;
counter_a=Close[6]+Close[5]+Close[4]+Close[3]+Close[2];
double denomimator_a=5;
double a=counter_a/denomimator_a;
double one_prim;
one_prim=a+b*2;
double two_prim;
two_prim=a+b;
double three_prim;
three_prim=a;
double four_prim;
four_prim=a-b;
double five_prim;
five_prim=a-2*b;
double counter_1;
counter_1=MathPow(Close[2]-one_prim,2);
double counter_2;
counter_2=MathPow(Close[3]-two_prim,2);
double counter_3;
counter_3=MathPow(Close[4]-three_prim,2);
double counter_4;
counter_4=MathPow(Close[5]-four_prim,2);
double counter_5;
counter_5=MathPow(Close[6]-five_prim,2);
double counter_S;
counter_S=counter_1+counter_2+counter_3+counter_4+counter_5;
double denominator_S=3;
double S;
S=MathSqrt(counter_S/denominator_S);
double average;
average=(Close[6]+Close[5]+Close[4]+Close[3]+Close[2])/5;
double V;
V=(S/average)*100;
Comment( "\n b=",b," \n a=",a," \n average=",average,"\n Counter S=",counter_S," \n S=",S," \n V=",V);
//if (morning=="buy" && evening=="buy"&& trade=="buy" && spadek=="buy" && b>0 && b<=0.0002 && V<0.002)
// if (morning=="buy" && evening=="buy"&& trade=="buy" && b>0 && b<=0.002 && V<0.003)
//if (morning=="buy" && evening=="buy"&& trade=="buy" && b>0.0003 && V<0.003)
if (morning=="buy" && evening=="buy"&& trade=="buy" && b>0 && b<0.0002 && V<0.003 && spadek=="buy")
{
//--- get minimum stop level
double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
Print("Minimum Stop Level=",minstoplevel," points");
double price=Ask;
//--- calculated SL and TP prices must be normalized
double stoploss=Ask-90*Point;
// double takeprofit=NormalizeDouble(Bid+80*Point,Digits);
double takeprofit=Ask+90*Point;
//--- place market order to buy 1 lot
int ticket=OrderSend(Symbol(),OP_BUY,0.1,price,5,stoploss,takeprofit,"My Order",16384,0,clrGreen);
Print (b," ",V);
//for (int c=OrdersTotal()-1;c>=0;c--)
//{
//if (OrderSelect(c,SELECT_BY_POS,MODE_TRADES))
//{
//if (OrderStopLoss()<(Ask-75*Point))
//OrderModify(
//OrderTicket(),
//OrderOpenPrice(),
//stoploss+0.0025,
//takeprofit,0,clrGreen);
// }
// }
}
}