One Click Close The script allows users to easily close positions if their profit/loss reaches or exceeds a value specified in pips. Please set slippage value first. Sometimes some positions do not close due to high volatility of the market. Please set larger slippage or restart the script. The free demo version is: ...
Para login e uso do site MQL5.com, você deve ativar o uso de cookies.
Ative esta opção no seu navegador, caso contrário você não poderá fazer login.
Você entrou na conta. A autenticação de dois fatores foi desativada. Configure-a novamente e escaneie um novo código QR ou continue com a autenticação de dois fatores desativada.
Bom dia, eu modifiquei um indicador para exibir na tela principal em vez de janela separada, porem, nao exibe a linha do indicador.
#property copyright "Alexandre Júnior"
#property link "http://www.mql5.com"
#property version "1.00"
#property description "Média Rápida"
#include <MovingAverages.mqh>
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1
//--- plot ExtMRBuffer
#property indicator_label1 "MR"
#property indicator_type1 DRAW_LINE
#property indicator_color1 Yellow
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
//--- default applied price
#property indicator_applied_price PRICE_CLOSE
//--- input parameters
input int InpMRPeriod=8; // MR period
input int InpMRShift=0; // MR shift
//--- indicator buffer
double ExtMRBuffer[];
double ExtMRBuffer2[];
int ExtMRPeriod;
int ExtMRShift;
//+------------------------------------------------------------------+
//| MR initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- check for input values
if(InpMRPeriod<=0)
{
ExtMRPeriod=17;
PrintFormat("Input parameter InpPeriodMR has incorrect value (%d). Indicator will use value %d for calculations.",
InpMRPeriod,ExtMRPeriod);
}
else
ExtMRPeriod=InpMRPeriod;
if(InpMRShift<0)
{
ExtMRShift=0;
printf("Incorrect value for input variable InpStdDevShift=%d. Indicator will use value=%d for calculations.",InpMRShift,ExtMRShift);
}
else ExtMRShift=InpMRShift;
//--- indicator buffers mapping
SetIndexBuffer(0,ExtMRBuffer,INDICATOR_DATA);
//--- set accuracy
IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//--- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtMRPeriod);
//--- set index shift
PlotIndexSetInteger(0,PLOT_SHIFT,InpMRShift);
//--- set shortname and change label
string short_name=StringFormat("MR(%d)",ExtMRPeriod);
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
PlotIndexSetString(0,PLOT_LABEL,short_name);
}
//+------------------------------------------------------------------+
//| AMA iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
int pos;
//--- check for rates count
//--- draw begin may be corrected
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtMRPeriod-1+begin);
if(rates_total<ExtMRPeriod)
return(0);
//--- detect position
pos=prev_calculated-1;
//--- first calculations
if(pos<ExtMRPeriod)
{
pos=ExtMRPeriod-1;
ArrayInitialize(ExtMRBuffer2,0.0);
ArrayInitialize(ExtMRBuffer,0.0);
}
//--- main cycle
for( int i=pos; i<rates_total && !IsStopped(); i++)
{
//--- calculate MR
if(i==InpMRPeriod-1)
ExtMRBuffer[i]=SimpleMA(i,InpMRPeriod,price);
else
ExtMRBuffer[i]=ExponentialMA(i,InpMRPeriod,ExtMRBuffer[i-1],price);
//--- Calculate StdDev
ExtMRBuffer2[i]=StdDevFunc(price,ExtMRBuffer,i);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| Calculate DESV value |
//+------------------------------------------------------------------+
double StdDevFunc(const double &price[],const double &ma_price[],int position)
{
double dev=0.0;
for(int i=0; i<ExtMRPeriod; i++)
dev+=MathPow(price[position-i]-ma_price[position],2);
dev=MathSqrt(dev/ExtMRPeriod);
return(dev);
}
//+------------------------------------------------------------------+