buferrs do indicador

Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se
olá pessoal,tudo bem?
sou iniciante na programação mql4
estou com um indicador de niveis redondos no qual estou tentando adicionar os buffers, mas até agora não consegui algém poderia me dizer o que está faltando ou o que esta errado
fiz o cabeçalho mas não coseui registrar os buffers.
//+--------------------------- ------------------------------ ---------+//| ROUND_LEVEL_.mq4 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+--------------------------- ------------------------------ ---------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_type1 DRAW_LINE
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_color1 C'85,198,136'
#property indicator_label1 "Lower1Line"
#property indicator_type2 DRAW_LINE
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#property indicator_color2 C'237,58,95'
#property indicator_label2 "Upper1Line"
#property indicator_type3 DRAW_LINE
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
#property indicator_color3 C'85,198,136'
#property indicator_label3 "Lower2Line"
#property indicator_type4 DRAW_LINE
#property indicator_style4 STYLE_SOLID
#property indicator_width4 1
#property indicator_color4 C'237,58,95'
#property indicator_label4 "Upper2Line"
#property indicator_type5 DRAW_LINE
#property indicator_style5 STYLE_SOLID
#property indicator_width5 3
#property indicator_color5 C'85,198,136'
#property indicator_label5 "Lower3Line"
#property indicator_type6 DRAW_LINE
#property indicator_style6 STYLE_SOLID
#property indicator_width6 3
#property indicator_color6 C'237,58,95'
#property indicator_label6 "Upper3Line"
//--- indicator buffers
double Lower1;
double Upper1;
double Lower2;
double Upper2;
double Lower3;
double Upper3;
//---- names of horizontal lines
string Lower1Line="Lower1Line";
string Upper1Line="Upper1Line";
string Lower2Line="Lower2Line";
string Upper2Line="Upper2Line";
string Lower3Line="Lower3Line";
string Upper3Line="Upper3Line";
//+--------------------------- ------------------------------ ---------+
//| Custom indicator initialization function |
//+--------------------------- ------------------------------ ---------+
int OnInit()
{
IndicatorBuffers(6);
SetIndexBuffer(0,Lower1);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexBuffer(1, Upper1);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexBuffer(2, Lower2);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexBuffer(3, Upper2);
SetIndexEmptyValue(3, EMPTY_VALUE);
SetIndexBuffer(4, Lower3);
SetIndexEmptyValue(4, EMPTY_VALUE);
SetIndexBuffer(5, Upper3);
SetIndexEmptyValue(5, EMPTY_VALUE);
//--- indicator buffers mapping
//ObjectsDeleteAll();
void OnDeinit()
{
//----
if(ObjectFind(Lower1Line)>0)
ObjectDelete(Lower1Line);
if(ObjectFind(Upper1Line)>0)
ObjectDelete(Upper1Line);
if(ObjectFind(Lower2Line)>0)
ObjectDelete(Lower2Line);
if(ObjectFind(Upper2Line)>0)
ObjectDelete(Upper2Line);
if(ObjectFind(Lower3Line)>0)
ObjectDelete(Lower3Line);
if(ObjectFind(Upper3Line)>0)
ObjectDelete(Upper3Line);
}
//+--------------------------- ------------------------------ ---------+
//| 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[])
{
int counted_bars=IndicatorCounted( );
Lower1=MathFloor((Close[0]/ Point)/100)*Point*100;
Upper1=MathCeil((Close[0]/ Point)/100)*Point*100;
Lower2=Lower1-100*Point;
Upper2=Upper1+100*Point;
Lower3=Lower2-100*Point;
Upper3=Upper2+100*Point;
int Lower1Width=1;
int Upper1Width=1;
int Lower2Width=1;
int Upper2Width=1;
int Lower3Width=1;
int Upper3Width=1;
if(MathMod(MathRound(Lower1/ Point),500)==0) Lower1Width=3;
if(MathMod(MathRound(Upper1/ Point),500)==0) Upper1Width=3;
if(MathMod(MathRound(Lower2/ Point),500)==0) Lower2Width=3;
if(MathMod(MathRound(Upper2/ Point),500)==0) Upper2Width=3;
if(MathMod(MathRound(Lower3/ Point),500)==0) Lower3Width=3;
if(MathMod(MathRound(Upper3/ Point),500)==0) Upper3Width=3;
if(ObjectFind(Lower1Line)==0) {
ObjectSet(Lower1Line,OBJPROP_ PRICE1,Lower1);
ObjectSet(Lower1Line,OBJPROP_ COLOR,C'85,198,136');
ObjectSet(Lower1Line,OBJPROP_ WIDTH,Lower1Width);
}
else ObjectCreate(Lower1Line,OBJ_ HLINE,0,D'2004.02.20 12:30',Lower1);
if(ObjectFind(Upper1Line)==0) {
ObjectSet(Upper1Line,OBJPROP_ PRICE1,Upper1);
ObjectSet(Upper1Line,OBJPROP_ COLOR,C'237,58,95');
ObjectSet(Upper1Line,OBJPROP_ WIDTH,Upper1Width);
}
else ObjectCreate(Upper1Line,OBJ_ HLINE,0,D'2004.02.20 12:30',Upper1);
if(ObjectFind(Lower2Line)==0) {
ObjectSet(Lower2Line,OBJPROP_ PRICE1,Lower2);
ObjectSet(Lower2Line,OBJPROP_ COLOR,C'85,198,136');
ObjectSet(Lower2Line,OBJPROP_ WIDTH,Lower2Width);
}
else ObjectCreate(Lower2Line,OBJ_ HLINE,0,D'2004.02.20 12:30',Lower2);
if(ObjectFind(Upper2Line)==0) {
ObjectSet(Upper2Line,OBJPROP_ PRICE1,Upper2);
ObjectSet(Upper2Line,OBJPROP_ COLOR,C'237,58,95');
ObjectSet(Upper2Line,OBJPROP_ WIDTH,Upper2Width);
}
else ObjectCreate(Upper2Line,OBJ_ HLINE,0,D'2004.02.20 12:30',Upper2);
if(ObjectFind(Lower3Line)==0) {
ObjectSet(Lower3Line,OBJPROP_ PRICE1,Lower3);
ObjectSet(Lower3Line,OBJPROP_ COLOR,C'85,198,136');
ObjectSet(Lower3Line,OBJPROP_ WIDTH,Lower3Width);
}
else ObjectCreate(Lower3Line,OBJ_ HLINE,0,D'2004.02.20 12:30',Lower3);
if(ObjectFind(Upper3Line)==0) {
ObjectSet(Upper3Line,OBJPROP_ PRICE1,Upper3);
ObjectSet(Upper3Line,OBJPROP_ COLOR,C'237,58,95');
ObjectSet(Upper3Line,OBJPROP_ WIDTH,Upper3Width);
}
else ObjectCreate(Upper3Line,OBJ_ HLINE,0,D'2004.02.20 12:30',Upper3);
return(rates_total);
}