Guarda come scaricare robot di trading gratuitamente
Ci trovi su Telegram!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Indicatori

Double ATR with crossing color signals - indicatore per MetaTrader 5

Visualizzazioni:
282
Pubblicato:
2023.09.13 00:56
Aggiornato:
2023.09.13 00:57
Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

Double ATR Image

//+------------------------------------------------------------------+
//|                                                  BPT_ATR_EVO.mq5 |
//|           Copyright 2023, Giorgio Scarabello - Blueprint Trading |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, Giorgio Scarabello - Blueprint Trading"
#property version   "1.00"
#property description   "BPT Average true range"
#property description   "by Blueprint Trading"
#property description   "Home of profitability"
//--- indicator settings
#property indicator_separate_window

#property indicator_buffers 6
#property indicator_plots   2


#property indicator_type1   DRAW_COLOR_HISTOGRAM
#property indicator_color1  clrDodgerBlue, clrRoyalBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  5
#property indicator_label1  "BPT_ATR_EVO A"
//
#property indicator_type2   DRAW_COLOR_LINE
#property indicator_color2  clrChartreuse, clrAzure
#property indicator_style2  STYLE_DOT
#property indicator_width2  1
#property indicator_label2  "BPT_ATR_EVO B"

//--- input parameters
input int InpAtrPeriod=3;     // ATR period A
input int InpAtrPeriodB=89;   // ATR period B

//--- indicator buffers
double    ATRBuffer[];
double    ATRBufferCol[];
double    TRBuffer[];
double    ATRBufferB[];
double    ATRBufferBCol[];
double    TRBufferB[];

int       PeriodATR;
int       PeriodATRB;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- check for input value
   if(InpAtrPeriod<=0 || InpAtrPeriod>=InpAtrPeriodB){
      PeriodATR=3;
      PrintFormat("Incorrect input parameter ATR period A = %d. Indicator will use value %d for calculations.",InpAtrPeriod,PeriodATR);
   }
   else{
      PeriodATR=InpAtrPeriod;
   }
   
   if(InpAtrPeriodB<=0){
      PeriodATRB=34;
      PrintFormat("Incorrect input parameter ATR period B = %d. Indicator will use value %d for calculations.",InpAtrPeriodB,PeriodATRB);
   }
   else{
      PeriodATRB=InpAtrPeriodB;
   }
   
//--- indicator buffers mapping
   SetIndexBuffer(0,ATRBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ATRBufferCol,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(2,ATRBufferB,INDICATOR_DATA);
   SetIndexBuffer(3,ATRBufferBCol,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(4,TRBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(5,TRBufferB,INDICATOR_CALCULATIONS);
//---
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpAtrPeriod);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpAtrPeriodB);
//--- name for DataWindow and indicator subwindow label
   string short_name=StringFormat("BPT_ATR_EVO(%d - %d)",PeriodATR, PeriodATRB);
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
   PlotIndexSetString(0,PLOT_LABEL,"BPT_ATR_EVO A("+IntegerToString(PeriodATR,0,' ')+")");
   PlotIndexSetString(1,PLOT_LABEL,"BPT_ATR_EVO B("+IntegerToString(PeriodATRB,0,' ')+")");
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
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[])
  {
   if(rates_total<=PeriodATR || rates_total<=PeriodATRB) return(0);

   int i,start;
//--- preliminary calculations
   if(prev_calculated==0){
      ArrayInitialize(ATRBuffer,0.0);
      ArrayInitialize(ATRBufferCol,0.0);
      ArrayInitialize(TRBuffer,0.0);
      ArrayInitialize(ATRBufferB,0.0);
      ArrayInitialize(ATRBufferBCol,0.0);
      ArrayInitialize(TRBufferB,0.0);
      //
      start=PeriodATRB+1;
   }
   else{
      start=prev_calculated-1;
   }
   
//--- the main loop of calculations
   for(i=start; i<rates_total && !IsStopped(); i++){
      TRBuffer[i]=MathAbs(MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]));
      ATRBuffer[i]=ATRBuffer[i-1]+(TRBuffer[i]-TRBuffer[i-PeriodATR])/PeriodATR;
      //
      TRBufferB[i]=TRBuffer[i];
      ATRBufferB[i]=ATRBufferB[i-1]+(TRBufferB[i]-TRBufferB[i-PeriodATRB])/PeriodATRB;
      //
      if(ATRBuffer[i]>ATRBufferB[i]){
         ATRBufferCol[i]=0.0;
         ATRBufferBCol[i]=1.0;
      }
      else if(ATRBuffer[i]<=ATRBufferB[i]){
         ATRBufferCol[i]=1.0;
         ATRBufferBCol[i]=0.0;
      }
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+



    Advisor Based on RSI and Martingale Advisor Based on RSI and Martingale

    "This advisor uses the RSI indicator to determine optimal entry and exit points in the market. A unique feature of the advisor is its martingale strategy, which allows for position reversal with an increased lot size during market reversals. The advisor offers flexible trading time settings: you can set a working time range and disable trading during specific hours to filter out news events."

    Automatic Chart Refresher Automatic Chart Refresher

    A tool which refreshes the chart automatically and will make active indicators update if something stopped plotting on the chart.

    Wick Ratio Candlesticks Wick Ratio Candlesticks

    Wick Ratio Candlesticks are recognized by its upper and lower wick ratio instead of open and close properties.

    Hull Moving Average Hull Moving Average

    Here is my implementation of a colored Hull Moving Average.