current bar and previous bar

Dinos
14

Hi friends

i have something to ask about ...and i would like to find some help

with short say, i cant to make simple indicator that can give me (price change)

i want to get the price change by differ the close for current bar and the close for the previous bar

i know maybe it's so simple ..but for me is very difficult so i would like if i find here some help

>>>the code below is my try to do what i wanted,but it was failed

#
#property link "www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int barsToProcess=100;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int i=0;i<Bars;i++)
{
ExtMapBuffer1[i]=Close[i]-Close[i-1];
}
return(0);
}
//+------------------------------------------------------------------+
Ray
2647
Ray  

Close for current bar is Close[0]. This price is the same as Bid. It may or may not be the final price received for this bar.

Close for the most recent completed bar is Close[1].

Close for the second most recently completed bar is Close[2].

Dinos
14
Dinos  

thank u so much ...but also i wanted to know if that is right or wrong?

int start()
{

for(int i=0;i<Bars;i++)


again thank u for ur help

Dinos
14
Dinos  

so sorry ..if i will not get u tired pleas i want the code that i can get the price change between the current bar and the previous bar


thank u a lot

Ray
2647
Ray  
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int i=Bars-2; i >= 0; i--)
{
ExtMapBuffer1[i]=Close[i]-Close[i+1];
}
return(0);
}
//+------------------------------------------------------------------+
Dinos
14
Dinos  
phy:
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int i=Bars-2; i >= 0; i--)
{
ExtMapBuffer1[i]=Close[i]-Close[i+1];
}
return(0);
}

//+----------------------------------------------------------------


thank u so much for ur help

all kind regards for u