помогите переделать индикатор)))

 

есть индикатор, не знаю как сделать так чтобы в параметрах линий trandline писалось не linestoporder1259640000 f имя line1259640000 и чтобы последующие линии trandline обозначались как 1259640001, 1259640002, 1259640003,

код индикатора

/*

*/
#include <stdlib.mqh>


#include <WinUser32.mqh>

//+------------------------------------------------------------------+
//| common.mq4 |
//| Copyright © 2007, Sergan |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Sergan"
#property link "Serganmt@hotbox.ru"

#define LOW 0
#define HIGH 1
#define OP_NONE -1 //тип ордера - нет ордера OP_BUY, OP_SELL и т.п. используются из мт
#define OP_CLOSEORDER -2 //тип сигнала - закрыть ордер
#define UP 1
#define DOWN -1
#define REVERSESTRING "reverseorder "
#define ZIGZAGTRADERSTRING "zt "


//+------------------------------------------------------------------+
//| ZigzagAtrLW.mq4 |
//| Copyright © 2007, Sergan |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Sergan"
#property link "Serganmt@hotbox.ru"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Black

#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 3
#property indicator_width6 4
//---- input parameters


extern int AtrPeriod=200; // период Atr
extern double K1=1.5; // коэффицент умножения зигзаг 1


double Buffer1[]; // буфер младший зигзаг

double BufferPoints1[]; //буфер опорных точек малого зигазга
double BufferPoints2[]; //буфер опорных точек старшего зигазга
double BuyBuffer[]; //буфер сигналы бай
double SellBuffer[]; //буяер сигналы селл

double BufferSignalType[]; // буфер типов сигналов, необходимо для передачи в советник

double LastAtr=1; int flagshow; int midlpoint=0;double RetVal ;// параметр разворота
int fixed; // бар, на котором определена последняя фиксированная точка



//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,Buffer1);
SetIndexEmptyValue(0,0.0);

SetIndexStyle(0,DRAW_SECTION, EMPTY, EMPTY); //SetIndexStyle(0,DRAW_SECTION, EMPTY, EMPTY, IndicatorColor);

SetIndexStyle( 2, DRAW_ARROW, EMPTY );
SetIndexArrow( 2, 233 );
SetIndexStyle( 3, DRAW_ARROW, EMPTY );
SetIndexArrow( 3, 234 );

SetIndexBuffer( 2, BuyBuffer );
SetIndexBuffer( 3, SellBuffer );
int drawtype = DRAW_ARROW ;
drawtype = DRAW_NONE; ////if( isshowsignaltype3 == 0 )
SetIndexBuffer( 4, BufferPoints1 );
SetIndexStyle( 4, drawtype, EMPTY );
SetIndexArrow( 4, 158); //точка
SetIndexEmptyValue(4,0.0);

SetIndexBuffer(7,BufferSignalType );
SetIndexStyle( 7, DRAW_NONE);
SetIndexEmptyValue(7,0);

return(0);
}




//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit(){ return(0); }


int definelastfixedpoint(int limit, double& BufferPoints[]){
for( int i = limit +1; i<Bars; i++ ){
if( Low[i] == BufferPoints[i] )return( i );
if( High[i] == BufferPoints[i] )return( i );
}
}

int CalcZigzag( double& ExtMapBuffer1[], int limit, double AtrMultiply, double& BufferPoints[]){
fixed = limit;
int typefixedpoint;
fixed = definelastfixedpoint(limit, BufferPoints);
for( int i = limit; i>0; i-- ){
typefixedpoint = HIGH;
if( Low[fixed] == BufferPoints[fixed] )typefixedpoint = LOW; // определили тип последнего экстремума
// если последний экстремум вверх, текущий хай выше его, то он становиться последним экстремумоа
if( typefixedpoint == HIGH && High[i]>BufferPoints[fixed]){
ExtMapBuffer1[fixed] = 0; //зигзаг удлинняется
fixed = i; BufferPoints[fixed] = High[i];
ExtMapBuffer1[fixed] = High[i]; //зигзаг удлинняется
continue;
}
// если последний экстремум вниз, текущие лоу ниже его, то он становиться последним экстремумоа
if( typefixedpoint == LOW && Low[i]<BufferPoints[fixed]){
ExtMapBuffer1[fixed] = 0; //зигзаг удлинняется
fixed = i; BufferPoints[fixed] = Low[i];
ExtMapBuffer1[fixed] = Low[i]; //зигзаг удлинняется
continue;
}
LastAtr =iATR(NULL, 0, AtrPeriod, i ) ; //PERIOD_H1
RetVal = LastAtr*AtrMultiply;
// если последний экстремум вверх, а текущее лоу ниже его больше чем на параметр разворота, то тип экстремума меняется
if( typefixedpoint == HIGH && High[fixed]-Low[i]> RetVal ){
fixed = i; BufferPoints[fixed]=Low[i]; typefixedpoint = LOW;
ExtMapBuffer1[fixed] = Low[i]; //зигзаг появляется
continue;
}
// если последний экстремум вниз, а текущий хай больше чем на параметр разворота, то тип экстремума меняется
if( typefixedpoint == LOW && -Low[fixed]+High[i]> RetVal ){
fixed = i; BufferPoints[fixed]=High[i]; typefixedpoint = HIGH;
ExtMapBuffer1[fixed] = High[i]; //зигзаг появляется
continue;
}
BufferPoints[i]=0; ExtMapBuffer1[i]=0; // необходимо убрать ранее расчитанные точки, т.к. при переключении таймфрейма или наложнеии на график другого инструмента буферы не инициализируются
continue;
}
////ExtMapBuffer1[lasti] =0;
//ExtMapBuffer1[0] = Close[0];
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start(){
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
// пересчитаем последний
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars-1;


CalcZigzag(Buffer1, limit, K1, BufferPoints1 );
for( int i = limit; i>0; i -- ){
ShowSignals(i);
}
return(0);
}
//+------------------------------------------------------------------+
int ShowSignals(int i ){

//BuyBuffer[i] = Low[i];
// условие покупки - ближайшая слева нижняя опорная точка выше чем предыдущая,
// минимальное условия для первой волны выполнено, лоу свечи, следующей за свечой, для которой выполнено условие второй
// волны должно быть выше ее лоу
BuyBuffer[i] = 0; SellBuffer[i] = 0; BufferSignalType[i]=OP_NONE;
//BufferSignalType[i] = -1;
string objname = "linestoporder"+Time[i];
ObjectDelete(objname );


int j;
int foundfirstlow = 0; int foundsecondlow = 0; int foundfirsthigh = 0; int foundsecondhigh = 0;
int direction = 0;
flagshow = 0;

int flag1, flag2;
// условие открытия установки бай стопа: существует сформированная опорная точка зигзага вниз
// ишется точка вверх левве ее, бай стоп устанавливается на +1 пункт
for(j = i; j<Bars && foundfirstlow == 0; j++)if(Low[j] == BufferPoints1[j])foundfirstlow = j;
if(foundfirstlow!=0){
for(j = foundfirstlow; j<Bars && foundfirsthigh == 0; j++)if(High[j] == BufferPoints1[j])foundfirsthigh = j;
}
flagshow = 1;
if( foundfirstlow * foundfirsthigh == 0)flagshow = 0;
if( flagshow ) {
// найдена опорная точка вниз, левее ее опорная точка вверх
for(j = i+1; j<foundfirsthigh;j++){
if( BufferSignalType[j] == OP_BUYSTOP ) flagshow = 0;
}
//и слева нет сигнала на бай
if( flagshow ){
BuyBuffer[i] = High[foundfirsthigh]+Point;
BufferSignalType[i]= OP_BUYSTOP;
direction = UP;
}
}

foundfirstlow = 0; foundsecondlow = 0; foundfirsthigh = 0; foundsecondhigh = 0;


// условие открытия установки селл стопа: существует сформированная опорная точка зигзага вверх
// ишется точка вверх левве ее, селл стоп устанавливается на -1 пункт
for(j = i; j<Bars && foundfirsthigh == 0; j++)if(High[j] == BufferPoints1[j])foundfirsthigh = j;
if(foundfirsthigh!=0){
for(j = foundfirsthigh; j<Bars && foundfirstlow == 0; j++)if(Low[j] == BufferPoints1[j])foundfirstlow = j;
}
flagshow = 1;
if( foundfirsthigh * foundfirstlow == 0)flagshow = 0;
if( flagshow ) {
// найдена опорная точка вниз, левее ее опорная точка вверх
for(j = i+1; j<foundfirstlow;j++){
if( BufferSignalType[j] == OP_SELLSTOP ) flagshow = 0;
}
//и слева нет сигнала на бай
if( flagshow ){
SellBuffer[i] = Low[foundfirstlow]-Point;
BufferSignalType[i]= OP_SELLSTOP;
direction = DOWN;
}
}

if ( direction !=0 ){
BufferSignalType[i] = iif(direction == UP, OP_BUYSTOP, OP_SELLSTOP);
double stoppos = iif(direction == UP, BuyBuffer[i], SellBuffer[i] );
int topoint = iif( direction == UP, foundfirsthigh, foundfirstlow );
// сдесь же нужно отразить линию бай/селл стоп
//Print("line show to point ", topoint );
ObjectCreate(objname, OBJ_TREND, 0, Time[topoint], stoppos, Time[i], stoppos );
ObjectSet(objname, OBJPROP_RAY, 0);
return ;

}



return( 0 );



}





int sign( double v ) {if( v < 0 ) return( -1 ); return( 1 ); }
double iif( bool condition, double ifTrue, double ifFalse ){ if( condition ) return( ifTrue ); return( ifFalse );}
string iifStr( bool condition, string ifTrue, string ifFalse ) { if( condition ) return( ifTrue ); return( ifFalse ); }
string SignalToStr(int sig ){
if( sig == OP_BUYLIMIT ) return ("OP_BUYLIMIT" );
if( sig == OP_SELLLIMIT ) return ("OP_SELLLIMIT" );
if( sig == OP_BUY ) return ("OP_BUY" );
if( sig == OP_BUYSTOP ) return ("OP_BUYSTOP" );
if( sig == OP_SELL ) return ("OP_SELL" );
if( sig == OP_SELLSTOP ) return ("OP_SELLSTOP" );
if( sig == OP_NONE ) return ("OP_NONE" );
if( sig == OP_CLOSEORDER ) return ("OP_CLOSEORDER" );

return ( "undefined type if signal "+ sig );

}







int getoldertimeframe(int passedframe=0){
int curper = Period();
if(passedframe!=0)curper=passedframe;

if( curper == PERIOD_M1 )return (PERIOD_M5);
if( curper == PERIOD_M5)return (PERIOD_M15);
if( curper == PERIOD_M15)return (PERIOD_M30);
if( curper == PERIOD_M30)return (PERIOD_H1);
if( curper == PERIOD_H1)return (PERIOD_H4);
if( curper == PERIOD_H4)return (PERIOD_D1);
if( curper == PERIOD_D1)return (PERIOD_W1);
if( curper == PERIOD_W1)return (PERIOD_MN1);
if( curper == PERIOD_MN1)return (0);
return (0);
}

// ---- Money Management








double LotSize(double StopLossInPips, double RiskPercent, int desigion=1, double addsumtodepo = 0 ){
int Leverage = AccountLeverage();
double PipValue = MarketInfo(Symbol(), MODE_TICKVALUE);
double lotMM, FreeMargin;
//Print("addsumtodepo is ", addsumtodepo );
FreeMargin = AccountBalance( )+addsumtodepo ; //AccountFreeMargin();
lotMM = NormalizeDouble((FreeMargin*RiskPercent/100)/(StopLossInPips*PipValue),desigion);
double minlot = 0.1;
Print("Цена пункта=", PipValue, " Свободные средства=", FreeMargin, " Риск=", RiskPercent, " Число лотов=", lotMM);
if(desigion == 2) minlot = 0.01;

if (lotMM < minlot ) lotMM = minlot ;//Lots;
if (lotMM > 100) lotMM = 100;
return (lotMM);
}


string PeriodToStr( int curper ){
if( curper == PERIOD_M1 )return ("M1");
if( curper == PERIOD_M5)return ("M5");
if( curper == PERIOD_M15)return ("M15");
if( curper == PERIOD_M30)return ("M30");
if( curper == PERIOD_H1)return ("H1");
if( curper == PERIOD_H4)return ("H4");
if( curper == PERIOD_D1)return ("D1");
if( curper == PERIOD_W1)return ("W1");
if( curper == PERIOD_MN1)return ("MN1");
return ("период не определен");

}