
www.opentraders.ru/downloads/2651/
В терминале есть линия которая отображается на всех ТФ
У меня не получается сложить название уровня с номером цикла.
Как правильно?
for(int i=0; i<ArraySize(level); i++)
{
PutHLine("Level "+(string)i,level[i],Red);
}
//+------------------------------------------------------------------+
//| Level.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
input double Lots = 0.1; // лот
input int StopLoss = 0; // лось
input int TakeProfit = 50; // язь
input int Slip = 30; // реквот
input int Magic = 123; // магик
input double Level1 = 1.07;
input double Level2 = 1.075;
input double Level3 = 1.08;
input double Level4 = 1.085;
input double Level5 = 1.09;
input double Level6 = 1.095;
datetime t=0;
double level[6];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
level[0]=Level1;
level[1]=Level2;
level[2]=Level3;
level[3]=Level4;
level[4]=Level5;
level[5]=Level6;
for(int i=0; i<ArraySize(level); i++)
{
PutHLine("Level "+(string)i,level[i],Red);
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//ObjectsDeleteAll(0,0,OBJ_HLINE);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0)
sl=NormalizeDouble(price+StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(price-TakeProfit*_Point,_Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0)
sl=NormalizeDouble(price-StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(price+TakeProfit*_Point,_Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,_Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| Горизонтальная линия |
//+------------------------------------------------------------------+
void PutHLine(string name,double p,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_HLINE,0,0,p);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(t!=Time[0])
{
for(int i=0; i<ArraySize(level); i++)
{
if(Close[1]>level[i] && Open[1]<level[i])
{
PutOrder(0,Ask);
}
if(Close[1]<level[i] && Open[1]>level[i])
{
PutOrder(1,Bid);
}
}
t=Time[0];
}
}
//+------------------------------------------------------------------+
Он вообще не появляется в списке индикаторов. После компиляции его тоже нет.
//+------------------------------------------------------------------+
//| Charts.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
double pr=0,p1=0,p2=0;
datetime t1=0,t2=0;
string nm="",sm="";
for(int i=0; i<ObjectsTotal(0,-1); i++)
{
if(ObjectGetInteger(0,ObjectName(0,i),OBJPROP_TYPE)==OBJ_HLINE)
{
nm=ObjectName(0,i);
pr=ObjectGetDouble(0,ObjectName(0,i),OBJPROP_PRICE);
sm=_Symbol;
Print("\n Name: ",nm);
Print("Price: ",pr);
Print("Symbol: ",sm);
}
}
int k=0;
long curr=0,prev=ChartFirst();
while(k<33)
{
curr=ChartNext(prev);
if(curr<0)
break;
if(nm!="" && ChartSymbol(curr)==sm)
{
ObjectCreate(curr,nm,OBJ_HLINE,0,0,NormalizeDouble(pr,_Digits));
}
if(nm=="")
{
ObjectsDeleteAll(curr,0,OBJ_HLINE);
}
prev=curr;
k++;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
www.opentraders.ru/downloads/2616/
AM2