#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightGray
#property indicator_color2 DarkOrchid
#property indicator_width1 2
#property indicator_width2 2
//---- indicator buffers
extern int period = 240;
extern bool show_speed = TRUE;
int limit;
double speed[];
double acceleration[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(2);
//---- drawing settings
if (show_speed == TRUE){
SetIndexStyle(0,DRAW_HISTOGRAM);
}else{
SetIndexStyle(0,DRAW_NONE);
}
SetIndexBuffer(0,speed);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,acceleration);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
//----
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++) {
speed[i] = iClose(Symbol(),0,i)-iClose(Symbol(),0,i+period);
}
for(i=0; i<limit; i++) {
acceleration[i] = speed[i]-speed[i+period];
}
//----
return(0);
}
//+------------------------------------------------------------------+
#property indicator_buffers 2
#property indicator_color1 LightGray
#property indicator_color2 DarkOrchid
#property indicator_width1 2
#property indicator_width2 2
//---- indicator buffers
extern int period = 240;
extern bool show_speed = TRUE;
int limit;
double speed[];
double acceleration[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(2);
//---- drawing settings
if (show_speed == TRUE){
SetIndexStyle(0,DRAW_HISTOGRAM);
}else{
SetIndexStyle(0,DRAW_NONE);
}
SetIndexBuffer(0,speed);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,acceleration);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
//----
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++) {
speed[i] = iClose(Symbol(),0,i)-iClose(Symbol(),0,i+period);
}
for(i=0; i<limit; i++) {
acceleration[i] = speed[i]-speed[i+period];
}
//----
return(0);
}
//+------------------------------------------------------------------+

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to bring up a ball, when the Buffer Histogram purple and Buffer line are not overlapped. the code written by me no errors.
#resource "\\Indicators\\price_speed_and_acceleration.ex4"
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_type1 DRAW_ARROW
#property indicator_width1 1
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"
//--- indicator buffers
double Buffer1[];
datetime time_alert; //used when sending alert
bool Audible_Alerts = true;
double myPoint; //initialized in OnInit
void myAlert(string type, string message)
{
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | Base1 @ "+Symbol()+","+Period()+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
else if(type == "indicator")
{
if(Audible_Alerts) Alert(type+" | Base1 @ "+Symbol()+","+Period()+" | "+message);
}
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(1);
SetIndexBuffer(0, Buffer1);
SetIndexEmptyValue(0, 0);
SetIndexArrow(0, 241);
//initialize myPoint
myPoint = Point();
if(Digits() == 5 || Digits() == 4 || Digits() == 3 || Digits() == 2)
{
myPoint *= 10;
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 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 limit = rates_total - prev_calculated;
//--- counting from 0 to rates_total
ArraySetAsSeries(Buffer1, true);
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Buffer1, 0);
}
int i = 0;
//---Pallino conferma segnale con Linea Viola non sovrapposta all'Histogramma---
bool Histo = iCustom(Symbol(), PERIOD_CURRENT, "::Indicators\\price_speed_and_acceleration.ex4", 240, true, 0, 1+i); // Histogramma
bool Viola = iCustom(Symbol(), PERIOD_CURRENT, "::Indicators\\price_speed_and_acceleration.ex4", 240, true, 1, 1+i); // Linea Viola
bool a = Histo > 0.0001
&& Histo < Viola;
bool b = Histo > 0.0001
&& Viola < -0.0001;
bool c = Histo < -0.0001
&& Viola < Histo;
bool d = Histo < -0.0001
&& Viola > 0.0001;
//Indicator Buffer 1
if(( a||b||c||d )
)
{
Buffer1[i] = Low[i]; //Set indicator value at Candlestick Low
if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar
}
return(rates_total);
}
//+------------------------------------------------------------------+