modifiquei esse indicador, porém estou com essa dificuldade, quero que a seta apareça somente se o candle terminar abaixou ou acima do value charts
#property copyright "2019, " // Copyright da empresa
#property version "2.0" // Versão do produto
#property description "Indicator" // Descrição do produto
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrBlue
#property indicator_color2 clrRed
#property indicator_width1 1
#property indicator_width2 1
enum aparvela
{
Imediato = 0,
ProxVela = 1
};
/////////////////////////////////////// SECURITY
////////////////////////////////////// SECURITY
extern string ma_set ="< Main Settings >";//>————————————————————————————————————————————————————————————————————————————————————————————————————————————
extern bool show_test_results = true;//Display Panel
extern int stop_x_bars=false;//Stop_X_Bars
extern int VC_Period=0;
extern int VC_NumBars=5;
extern int VC_Bars2Check=300;
extern bool VC_DisplayChart=0;
extern bool VC_DisplaySR=0;
extern bool VC_UseClassicColorSheme=0;
extern bool VC_UseDynamicSRLevels=0;
extern int VC_DynamicSRPeriod=500;
extern double VC_DynamicSRHighCut=0.02;
extern double VC_DynamicSRMediumCut=0.05;
extern double VC_Overbought=8.0;
extern double VC_SlightlyOverbought=8.0;
extern double VC_SlightlyOversold=-8.0;
extern double VC_Oversold=-8.0;
extern bool VC_AlertON=0;
extern double VC_AlertSRAnticipation=1.0;
extern string mt_set = "< Gale Settings >";//>———————————————————————————————————————————————————————————————————————————————————————————————————————————
extern bool use_martini=true;//use_gale
extern int martini_max_trades=2;//gale_max_trades
extern string al_set ="< Alert Settings >";//>———————————————————————————————————————————————————————————————————————————————————————————————————————————
extern bool use_alert=true;
extern string up_alert = "Call Now!";
extern string down_alert = "Put Now!";
extern string ar_set ="< Arrow Settings >";//>———————————————————————————————————————————————————————————————————————————————————————————————————————————
extern int arrow_indent=1; // arrow_distance
extern int up_arrow_code = 233;
extern int down_arrow_code = 234;
extern string is_set ="< Info Settings >";//>————————————————————————————————————————————————————————————————————————————————————————————————————————————
extern int info_X = 750;
extern int info_Y = 40;
extern int info_size = 10;
extern int info_Y_plus = 10;//info_distance
extern string info_font="Courier New";
extern color info_color1 = clrYellow;
extern color info_color2 = clrYellow;
extern color panel_color=clrBlack;
extern int panel_border_type=0;
extern int panel_hor_size=370;
extern int panel_vert_size=50;
extern int panel_hor_distance=730;
extern int panel_vert_distance=40;
string panel="panel";
string name="info_bo_1";
string name2="info_bo_1+2";
int point_koef = 10;
double Poin;
double up_arr[];
double down_arr[];
int prev_bars;
int shift_time;
int mart_seq_lost=0;
datetime sigtime;
//////////////////////////////////////////////
int OnInit()
{
IndicatorBuffers(2);
SetIndexBuffer(0,up_arr);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,up_arrow_code);
SetIndexLabel(0,"UP arrow");
SetIndexBuffer(1,down_arr);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,down_arrow_code);
SetIndexLabel(1,"DOWN arrow");
return(INIT_SUCCEEDED);
}
/////////////////////////////////////////////////////////
void OnDeinit(const int reason)
{
ObjectDelete(name);
ObjectDelete(name2);
ObjectDelete(panel);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],const double &open[],const double &Close[],
const double &low[],const double &close[],const long &tick_volume[],const long &volume[],const int &spread[])
{
//no bars
if(Bars<20) return(rates_total);
Poin = Point;
if ((Point == 0.00001) || (Point == 0.001)) Poin *= 10;
//history update
int all=rates_total;
int counted=prev_calculated;
if(all-counted>1)
{
ArrayInitialize(up_arr,EMPTY_VALUE);
ArrayInitialize(down_arr,EMPTY_VALUE);
counted=0;
}
int limit=MathMin(all-counted,VC_Bars2Check);
if(show_test_results) {display_panel();}
double TS_b,TS_s;
//MAIN LOOP
for(int i=limit+1;i>=0;i--)
{
if(i>Bars-20) i=Bars-20;
TS_b=iCustom(_Symbol,PERIOD_CURRENT,"TS_ValueCharts ",
VC_Period,
VC_NumBars,
VC_Bars2Check,
VC_DisplayChart,
VC_DisplaySR,
VC_UseClassicColorSheme,
VC_UseDynamicSRLevels,
VC_DynamicSRPeriod,
VC_DynamicSRHighCut,
VC_DynamicSRMediumCut,
VC_Overbought,
VC_SlightlyOverbought,
VC_SlightlyOversold,
VC_Oversold,
VC_AlertON,
VC_AlertSRAnticipation,
1,i);
TS_s=iCustom(_Symbol,PERIOD_CURRENT,"TS_ValueCharts ",
VC_Period,
VC_NumBars,
VC_Bars2Check,
VC_DisplayChart,
VC_DisplaySR,
VC_UseClassicColorSheme,
VC_UseDynamicSRLevels,
VC_DynamicSRPeriod,
VC_DynamicSRHighCut,
VC_DynamicSRMediumCut,
VC_Overbought,
VC_SlightlyOverbought,
VC_SlightlyOversold,
VC_Oversold,
VC_AlertON,
VC_AlertSRAnticipation,
0,i);
// buf 0 = máxima
// buf 1 = mínima
//Comment(TS_b);
if(TS_b!=EMPTY_VALUE && TS_b<=VC_Oversold) up_arr[i]=Low[i]-arrow_indent*Poin;
if(TS_s!=EMPTY_VALUE && TS_s>=VC_Overbought) down_arr[i]=High[i]+arrow_indent*Poin;
//alerts
if(use_alert)
{
if(up_arr[0]!=EMPTY_VALUE && sigtime!=Time[0])
{
Alert("AND_TSVC"," ",Symbol()," ","M",Period()," ",up_alert);
sigtime=Time[0];
}
//---
if(down_arr[0]!=EMPTY_VALUE && sigtime!=Time[0])
{
Alert("AND_TSVC"," ",Symbol()," ","M",Period()," ",down_alert);
sigtime=Time[0];
}
}
//trade interval
if(up_arr[i]!=EMPTY_VALUE || down_arr[i]!=EMPTY_VALUE) i-=stop_x_bars;
} //END MAIN LOOP
//------------------------------------------------------------------//
double wins=0;
double loses=0;
int mart_cou=0;
mart_seq_lost=0;
//STATISTICS LOOP
for(int i=VC_Bars2Check;i>=0;i--)
{
if(i>Bars-20) i=Bars-20;
//---
if(up_arr[i+1]!=EMPTY_VALUE)//////////////
{
if(Close[i]>Open[i])
{
wins++;
mart_cou=0;
}
else
if(Close[i]<=Open[i])
{
loses++;
if(use_martini) chek_martin_candle_f(i,1);
}
}
if(down_arr[i+1]!=EMPTY_VALUE)/////////////
{
if(Close[i]<Open[i])
{
wins++;
mart_cou=0;
}
else
if(Close[i]>=Open[i])
{
loses++;
if(use_martini) chek_martin_candle_f(i,-1);
}
}
}
//---
if (loses==0) loses=0.0000001;
double martini_itm_perc=(loses-mart_seq_lost)*100/(loses);
double perc100_=100;
if(wins+loses==0) {wins=0.0000001;loses=0.0000001;perc100_=0;}
if (!use_martini) martini_max_trades=0;
if (martini_max_trades==0) use_martini=false;
double martini_win=loses-mart_seq_lost;
double martini_total=loses;
if (martini_win==0.0000001 && martini_total==0.0000001) martini_itm_perc=0;
//---
string object=StringConcatenate("Trades: ",MathFloor(wins+loses)," ","Win: ",MathFloor(wins)," ","Loss: ",MathFloor(loses)," ","WR%: ",DoubleToString(perc100_/(wins+loses)*wins,1)+"%");
string object2=StringConcatenate("Gale ITM%: ",DoubleToString(martini_win,0)," ","out of"," ",DoubleToString(martini_total,0)," ","(",DoubleToString(martini_itm_perc,1),"%)");
if (!use_martini) object2=StringConcatenate("Gale ITM%: ",DoubleToString(0,0)," ","out of"," ",DoubleToString(0,0)," ","(",DoubleToString(0,1),"%)");
//---
if (!show_test_results)
{
object=StringConcatenate("");
object2=StringConcatenate("");
}
int Y=info_Y;
//---
if(ObjectFind(name)==-1) obj_create_f(name,Y,info_color1); Y+=info_Y_plus+10;
ObjectSetString(0,name,OBJPROP_TEXT,object);
if(ObjectFind(name2)==-1) obj_create_f(name2,Y,info_color2); Y+=info_Y_plus;
ObjectSetString(0,name2,OBJPROP_TEXT,object2);
//---
return(rates_total);
}//end on OnCalculate
//-------------------------------------------------------------------------------//
void obj_create_f(string name_,int Y,color col)
{
ObjectCreate(0,name_,OBJ_LABEL,0,0,0);
ObjectSetInteger(0,name_, OBJPROP_XDISTANCE,info_X);
ObjectSetInteger(0,name_, OBJPROP_YDISTANCE, Y);
ObjectSetInteger(0,name_, OBJPROP_FONTSIZE, info_size);
ObjectSetInteger(0,name_, OBJPROP_COLOR, col);
ObjectSetString(0,name_, OBJPROP_FONT, info_font);
}
//----------------------------------------------------------------------//
void display_panel () {
ObjectCreate(0,panel,OBJ_RECTANGLE_LABEL,0,0,0);
ObjectSetInteger(0,panel,OBJPROP_XDISTANCE,panel_hor_distance);//8
ObjectSetInteger(0,panel,OBJPROP_YDISTANCE,panel_vert_distance);//19
ObjectSetInteger(0,panel,OBJPROP_BORDER_TYPE,panel_border_type);
ObjectSetInteger(0,panel,OBJPROP_XSIZE,panel_hor_size);//355
ObjectSetInteger(0,panel,OBJPROP_YSIZE,panel_vert_size);//275
ObjectSetInteger(0,panel,OBJPROP_BGCOLOR,panel_color); //Black
ObjectSetInteger(0,panel,OBJPROP_SELECTABLE,FALSE);
ObjectSetInteger(0,panel,OBJPROP_SELECTED,FALSE);
ObjectSetInteger(0,panel,OBJPROP_BACK,TRUE);
}
//----------------------------------------------------------------//
void chek_martin_candle_f(int y,int way)
{
int loses=1;
for(int i=y-1;i>0;i--)
{
if(way==1)
{
if(Close[i]<Open[i])
{
loses++;
if(use_martini && loses>martini_max_trades) {mart_seq_lost++; break;}
}
else
if(Close[i]>Open[i])
{
break;
}
}
//---
if(way==-1)
{
if(Close[i]>Open[i])
{
loses++;
if(use_martini && loses>martini_max_trades) {mart_seq_lost++;break;}
}
else
if(Close[i]<Open[i])
{
break;
}
}
}
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
////////////////////////////////////////////////
![MQL5 - Linguagem para estratégias de negociação inseridas no terminal do cliente MetaTrader 5](https://c.mql5.com/i/registerlandings/logo-2.png)
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