Dear Mods, sorry would you please move my post below to programmijng forum thanks....
Dear Fellow Traders,
I'm learning to develop a simple EA based on Chandelier Stops v1.1. One thing that's bugging me is how to extract the correct value of Chandelier as seen on the Chart. I've checked on "Journal" sections of my strategy tester
and found out that the values of the Chandelier Up/Dn are not the same (worse yet, the offset is not constant but vary non-linearly) with the values seen on the time chart except at the very end of the data. (Im using 4 hour chart ). I've been trying days and nights to find the real bug in the code but to no avail. So, i'm pretty sure that the code is all correct but how come the result on the plot is not the same with the computed values as in my expert journal ). I've tried to twist the code around and around but nothing worked..
Any help will be gladly appreciated, please......... thx much
my variabloe declaration is as follows
double CHAND_H4_Val1 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 0, Current + 0);
double CHAND_H4_Val2 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 1, Current + 0);
double CHAND_H4_Val3 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 2, Current + 0);
double CHAND_H4_Val4 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 3, Current + 0);
On the same time/date - none of the 4 values above (even when it's shifted)matches with the chandelier values as i see them on the plot; except the last values at the very end of the plot.
Below is the chandelier code i'm using :
//+------------------------------------------------------------------+
//| ChandelierExit.mq4 |
//| MQLService |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "MQLService"
#property link "[email protected]"
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 Yellow
//---- input parameters
extern int Range=15;
extern int Shift=1;
extern int ATRPeriod=14;
extern int MultipleATR=3;//4;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
int direction=1;
double ATRvalue;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexEmptyValue(3,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
ATRvalue=iATR(NULL,0,ATRPeriod,0)*MultipleATR;
ExtMapBuffer1[i]=High[Highest(NULL,0,MODE_HIGH,Range,i+Shift)]-ATRvalue;
ExtMapBuffer2[i]=Low[Lowest(NULL,0,MODE_LOW,Range,i+Shift)]+ATRvalue;
if(direction==1)
{
if(Close[i+1]<ExtMapBuffer1[i+1])
{
direction=-1;
ExtMapBuffer3[i]=ExtMapBuffer2[i];
}
else
ExtMapBuffer3[i]=ExtMapBuffer1[i];
}
if(direction==-1)
{
if(Close[i+1]>ExtMapBuffer2[i+1])
{
direction=1;
ExtMapBuffer4[i]=ExtMapBuffer1[i];
}
else
ExtMapBuffer4[i]=ExtMapBuffer2[i];
}
}
return(0);
}
//+------------------------------------------------------------------+
Dear Fellow Traders,
I'm learning to develop a simple EA based on Chandelier Stops v1.1. One thing that's bugging me is how to extract the correct value of Chandelier as seen on the Chart. I've checked on "Journal" sections of my strategy tester
and found out that the values of the Chandelier Up/Dn are not the same (worse yet, the offset is not constant but vary non-linearly) with the values seen on the time chart except at the very end of the data. (Im using 4 hour chart ). I've been trying days and nights to find the real bug in the code but to no avail. So, i'm pretty sure that the code is all correct but how come the result on the plot is not the same with the computed values as in my expert journal ). I've tried to twist the code around and around but nothing worked..
Any help will be gladly appreciated, please......... thx much
my variabloe declaration is as follows
double CHAND_H4_Val1 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 0, Current + 0);
double CHAND_H4_Val2 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 1, Current + 0);
double CHAND_H4_Val3 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 2, Current + 0);
double CHAND_H4_Val4 = iCustom(NULL,PERIOD_H4,"Chandelier Exit", 3, Current + 0);
On the same time/date - none of the 4 values above (even when it's shifted)matches with the chandelier values as i see them on the plot; except the last values at the very end of the plot.
Below is the chandelier code i'm using :
//+------------------------------------------------------------------+
//| ChandelierExit.mq4 |
//| MQLService |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "MQLService"
#property link "[email protected]"
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 Yellow
//---- input parameters
extern int Range=15;
extern int Shift=1;
extern int ATRPeriod=14;
extern int MultipleATR=3;//4;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
int direction=1;
double ATRvalue;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexEmptyValue(3,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
ATRvalue=iATR(NULL,0,ATRPeriod,0)*MultipleATR;
ExtMapBuffer1[i]=High[Highest(NULL,0,MODE_HIGH,Range,i+Shift)]-ATRvalue;
ExtMapBuffer2[i]=Low[Lowest(NULL,0,MODE_LOW,Range,i+Shift)]+ATRvalue;
if(direction==1)
{
if(Close[i+1]<ExtMapBuffer1[i+1])
{
direction=-1;
ExtMapBuffer3[i]=ExtMapBuffer2[i];
}
else
ExtMapBuffer3[i]=ExtMapBuffer1[i];
}
if(direction==-1)
{
if(Close[i+1]>ExtMapBuffer2[i+1])
{
direction=1;
ExtMapBuffer4[i]=ExtMapBuffer1[i];
}
else
ExtMapBuffer4[i]=ExtMapBuffer2[i];
}
}
return(0);
}
//+------------------------------------------------------------------+