-
When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum - It displays a histogram (a vertical bar) on top of your chart. That has nothing to do with candlesticks.
- If you want it to display as a candlestick, you'll have to add another pair of buffers, and change their size. Look how the Heiken Ashi indicator does it.
I already "showed you what the code would be" had you bothered to look up the indicator mentioned.
You have only four choices:
- Search for it,
- learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
- Beg at Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum or Need help with coding - General - MQL5 programming forum or Free MQL4 To MQL5 Converter - General - MQL5 programming forum or Requests & Ideas (MQL5 only!),
- or pay (Freelance) someone to code it.
No free help
urgent help.
I already "showed you what the code would be" had you bothered to look up the indicator mentioned.
You have only four choices:
- Search for it,
- learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
- Beg at Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum or Need help with coding - General - MQL5 programming forum or Free MQL4 To MQL5 Converter - General - MQL5 programming forum or Requests & Ideas (MQL5 only!),
- or pay (Freelance) someone to code it.
No free help
urgent help.
@whroeder1 - If your demeanor on this forum is going to be that of negative towards novice MT4 coders, then please find another profession. If all you can do is provide a general template of an answer, then don't respond and let others (who have helped me before) provide me the code I am asking for. Once a code is provided, that is MY WAY of learning for future development how to implement it on the next go around. As you can CLEARLY see, I am not asking someone on this forum to code me an indicator that I thought up. So get lost already dude.
With that said, is anyone else out there kind enough to show me what and where the code would be implemented to reflect candlesticks instead of bars in the Source Code listed above?
Dear Volcom,
Try this after int init()
int Chart_ID; ChartSetInteger(Chart_ID,CHART_MODE,CHART_CANDLES);
Read reference manual Chart Properties
Get yourself a copy of this book, it is very helpful Expert Advisor Programming for MetaTrader 4
Also use SRC to post code.
Dear Volcom,
Try this after int init()
Read reference manual Chart Properties
Get yourself a copy of this book, it is very helpful Expert Advisor Programming for MetaTrader 4
Also use SRC to post code.
Hi @GrumpyDuckMan,
I get three errors when placing this code and still can't quite figure it out. I scanned through the Cart Properties manual and still unsure. Any ideas?
Line 43) 'int' - semicolon expected
Line 44) 'ChartSetInteger' - declaration without type
Line 46) '{' function definition unexpected
34)//------------------------------------------------------------------- 35)// 36)// 37// 38)// 39)// 40) 41)int init() 42) 43)int ChartID; 44) ChartSetInteger(ChartID,CHART_MODE,CHART_CANDLES); 45) 46){ 47) IndicatorBuffers(4); 48) SetIndexBuffer(0,bartu); SetIndexStyle(0,DRAW_HISTOGRAM); 49) SetIndexBuffer(1,bartd); SetIndexStyle(1,DRAW_HISTOGRAM); 50) SetIndexBuffer(2,vel); 51) SetIndexBuffer(3,trend); 52) return(0); 53)} 54)int deinit() { return(0); } 55) 56) //-------------------------------------------------------------------
Hi @GrumpyDuckMan,
I get three errors when placing this code and still can't quite figure it out. I scanned through the Cart Properties manual and still unsure. Any ideas?
Line 43) 'int' - semicolon expected
Line 44) 'ChartSetInteger' - declaration without type
Line 46) '{' function definition unexpected
//+------------------------------------------------------------------+ //| Open.mq4 | //| CK1 | //| https://www.mql5.com | //+------------------------------------------------------------------+ //------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Lime #property indicator_color2 Red // // // // // //extern int Length = 8; //extern int Price = PRICE_CLOSE; // // // // // double bartu[]; double bartd[]; double trend[]; double vel[]; //------------------------------------------------------------------- // //------------------------------------------------------------------- // // // // // int init() { int Chart_ID; ChartSetInteger(Chart_ID,CHART_MODE,CHART_CANDLES); IndicatorBuffers(4); SetIndexBuffer(0,bartu); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,bartd); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,vel); SetIndexBuffer(3,trend); return(0); } int deinit() { return(0); } //------------------------------------------------------------------- // //------------------------------------------------------------------- // // // // // int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit = MathMin(Bars-counted_bars,Bars-1); // // // // // for(int i=limit; i>=0; i--) { //vel[i] = iVelocity(iMA(NULL,0,1,0,MODE_SMA,Price,i),Length,i); vel[i] = iMA(NULL,0,8,0,MODE_EMA,0,i); bartu[i] = EMPTY_VALUE; bartd[i] = EMPTY_VALUE; if (iClose(NULL,0,i )> vel[i]) trend[i] = 1; if (iClose(NULL,0,i) < vel[i]) trend[i] = -1; if (trend[i]== 1) { bartu[i] = High[i]; bartd[i] = Low[i]; } if (trend[i]==-1) { bartd[i] = High[i]; bartu[i] = Low[i]; } } return(0); } //------------------------------------------------------------------- // //------------------------------------------------------------------- //This error should have given it away Line 46) '{' function definition unexpected
Thanks @GrumpyDuckMan,
The code came back with no errors which is great. However, it still reflects bars only instead of candlesticks.
Thanks @GrumpyDuckMan,
The code came back with no errors which is great. However, it still reflects bars only instead of candlesticks.
I edited your code, here it is. It works for me
//+------------------------------------------------------------------+ //| Open.mq4 | //| CK1 | //| https://www.mql5.com | //+------------------------------------------------------------------+ //------------------------------------------------------------------ #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Lime #property indicator_color2 Red #property indicator_maximum 1 #property indicator_minimum 0 double bartu[]; double bartd[]; double trend[]; double vel[]; int init() { int Chart_ID; ChartSetInteger(Chart_ID,CHART_SCALE,2); ChartSetInteger(Chart_ID,CHART_SHIFT,1); ChartSetInteger(Chart_ID,CHART_MODE,CHART_CANDLES); ChartSetInteger(Chart_ID,CHART_SHOW_GRID,false); IndicatorBuffers(4); SetIndexBuffer(0,bartu); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,bartd); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,vel); SetIndexBuffer(3,trend); return(0); } int deinit() { return(0); } int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(1); if(counted_bars>0) counted_bars--; int limit = MathMin(Bars-counted_bars,Bars-1); for(int i=limit; i>0; i--) { vel[i] = iMA(NULL,0,8,0,MODE_EMA,0,i); if (iClose(NULL,0,i)> vel[i]) trend[i] = 0; if (iClose(NULL,0,i) < vel[i]) trend[i] = 1; if (trend[i]== 1) { bartu[i] = High[i]; bartd[i] = Low[i]; } } return(0); } //------------------------------------------------------------------- // //------------------------------------------------------------------- //
I edited your code, here it is. It works for me
@GrumpyDuckMan - Can you attach a screenshot of what your chart looks like? When I applied the MT4 code, all I got was lines (attached).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
Can anyone tell me how to convert the source code below from Bar to Candlestick? Right now it only shows bars even when I choose the Candlestick option in MT4.
//+------------------------------------------------------------------+
//| Open.mq4 |
//| CK1 |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//
//
//
//
//
//extern int Length = 8;
//extern int Price = PRICE_CLOSE;
//
//
//
//
//
double bartu[];
double bartd[];
double trend[];
double vel[];
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//
int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0,bartu); SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(1,bartd); SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(2,vel);
SetIndexBuffer(3,trend);
return(0);
}
int deinit() { return(0); }
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit = MathMin(Bars-counted_bars,Bars-1);
//
//
//
//
//
for(int i=limit; i>=0; i--)
{
//vel[i] = iVelocity(iMA(NULL,0,1,0,MODE_SMA,Price,i),Length,i);
vel[i] = iMA(NULL,0,8,0,MODE_EMA,0,i);
bartu[i] = EMPTY_VALUE;
bartd[i] = EMPTY_VALUE;
if (iClose(NULL,0,i )> vel[i]) trend[i] = 1;
if (iClose(NULL,0,i) < vel[i]) trend[i] = -1;
if (trend[i]== 1) { bartu[i] = High[i]; bartd[i] = Low[i]; }
if (trend[i]==-1) { bartd[i] = High[i]; bartu[i] = Low[i]; }
}
return(0);
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//