//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void ModeOOP()
{
bool m;
double delta=0,oop=0,sl=0,tp=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUYSTOP)
{
delta=NormalizeDouble(OrderOpenPrice()-Bid,Digits);
if(delta>Delta*Point)
{
oop=NormalizeDouble(Bid+Delta*Point,Digits);
if(StopLoss>0) sl=NormalizeDouble(oop-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(oop+TakeProfit*Point,Digits);
m=OrderModify(OrderTicket(),oop,sl,tp,0,Blue);
return;
}
}
if(OrderType()==OP_SELLSTOP)
{
delta=NormalizeDouble(Bid-OrderOpenPrice(),Digits);
if(delta>Delta*Point)
{
oop=NormalizeDouble(Bid-Delta*Point,Digits);
if(StopLoss>0) sl=NormalizeDouble(oop+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(oop-TakeProfit*Point,Digits);
m=OrderModify(OrderTicket(),oop,sl,tp,0,Red);
return;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| ADXL.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int MAPeriod=50;
input int ADXPeriod=14;
input int RSIPeriod=14;
input int RSILevel=40;
input int ADXLevel=45;
input int Count=5;
input int Length=10;
input int Barov=111;
input ENUM_TIMEFRAMES tf=PERIOD_H1;
int k=0;
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
ObjectsDeleteAll(0,0,OBJ_ARROW_LEFT_PRICE);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
ObjectsDeleteAll();
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void LeftPrice(string name,datetime time,double price)
{
ObjectCreate(0,name,OBJ_ARROW_LEFT_PRICE,0,time,price);
//--- установим цвет метки
ObjectSetInteger(0,name,OBJPROP_COLOR,Red);
//--- установим стиль окаймляющей линии
ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
//--- установим размер метки
ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutTrendLine(string name,datetime time1,double price1,datetime time2,double price2,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_TREND,0,time1,price1,time2,price2);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим стиль отображения линии
ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_DOT);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправо
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
if(t!=time[0])
{
for(int i=0;i<Barov;i++)
{
double adx1=iADX(NULL,tf,ADXPeriod,0,0,i);
double adx2=iADX(NULL,tf,ADXPeriod,0,0,i+1);
double rsi=iRSI(NULL,tf,RSIPeriod,0,i);
double ao=iAO(NULL,tf,i);
double ma=iMA(NULL,tf,MAPeriod,0,1,0,i);
if(adx1>ADXLevel && adx2<ADXLevel && close[i]>ma && rsi>100-RSILevel && ao>0)
{
if(i>Length) PutTrendLine("Line "+(string)time[i],time[i],close[i],time[i-Length],close[i],Red);
Alert(_Symbol+": "+"Нарисовался верхний уровень!");
LeftPrice("Arrow "+(string)time[i],time[i],close[i]);
k++;
}
if(adx1>ADXLevel && adx2<ADXLevel && close[i]<ma && rsi<RSILevel && ao<0)
{
if(i>Length) PutTrendLine("Line "+(string)time[i],time[i],close[i],time[i-Length],close[i],Red);
Alert(_Symbol+": "+"Нарисовался нижний уровень!");
LeftPrice("Arrow "+(string)time[i],time[i],close[i]);
k++;
}
if(k>=Count) break;
t=time[0];
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2