How to draw secondary indicators on chart?

 
Hi I'm working on a custom MACD-based indicator which works in a separate window; however, I have two MAs declared in the code (using iMA) which I'd like to show on the chart the indicator's attached to. How do I do that?
 

You can use function ChartIndicatorAdd():

ChartIndicatorAdd

Adds an indicator with the specified handle into a specified chart window.

bool  ChartIndicatorAdd(
   long  chart_id,                 // chart ID
   int   sub_window                // number of the sub-window
   int   indicator_handle          // handle of the indicator
   );


Where sub_window is from ChartIndicatorName()
 
Rosh:

You can use function ChartIndicatorAdd():

Where sub_window is from ChartIndicatorName()
Thanks! How do I change the indicator's line type and color once I've created it?
 
cuallito:
Thanks! How do I change the indicator's line type and color once I've created it?
See function IndicatorSetInteger() and Connection between Indicator Properties and Functions
 

How to get Properties and parameters of an indicator on chart?

For example: an indicator Boll Band on chart, how to know the details of it such as: shift, deviations, apply price..., I say in MQL5

 

At the moment these features are not available from MQL5.
 
hi, i'll go crazy... my code

 ResetLastError();
 h_hashi1 = iCustom(Symbol(), PERIOD_M1, "heiken_ashi_tf1");
 Print("h_hashi1 = ",h_hashi1,"  error = ",GetLastError());
 
 //ChartIndicatorDelete(0,2,"heiken_ashi_tf1"); needed???
 ChartIndicatorAdd(0,2,h_hashi1); // Heiken Ashi soll in Subwindow 2
 
 ResetLastError();
 h_hashi2 = iCustom(Symbol(), PERIOD_M5, "heiken_ashi_tf2");
 Print("h_hashi2 = ",h_hashi2,"  error = ",GetLastError());
 
 //ChartIndicatorDelete(0,3,"heiken_ashi_tf2");
 ChartIndicatorAdd(0,3,h_hashi2); // Heiken Ashi soll in Subwindow 3

first try was with one file in indicators "heiken_ashi_tf" but it only loads one of the heiken ashi into my ea ;(

i also tought it is ab problem with instances and renamed the file to heiken_ashi_tf1 & heiken_ashi_tf2 for using with different handles like above...

in heiken_ashi_tf1 & heiken_ashi_tf2 is

#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots   1

#property indicator_type1   DRAW_COLOR_CANDLES
#property indicator_color1  DodgerBlue, Red
#property indicator_label1  "Open;High;Low;Close"

//--- indicator buffers
int    ARR_VAL;
int    ARR_COUNTER;
double ExtOBuffer[];
double ExtHBuffer[];
double ExtLBuffer[];
double ExtCBuffer[];
double ExtDBuffer[];
double ExtColorBuffer[];

////////////////////////////////////////////////////////////////////////////////////////////
// INIT
void OnInit(){

 ////////////////////////////
 ARR_VAL     = 0;
 ARR_COUNTER = 0;
 
 SetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA);
 SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA);
 SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA);
 SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA);
 SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX);
 SetIndexBuffer(5,ExtDBuffer,INDICATOR_CALCULATIONS);
 
 IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
 IndicatorSetString(INDICATOR_SHORTNAME,"heiken_ashi_tf1"); // in heiken_ashi_tf2 is shortname heiken_ashi_tf2
 PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
 
 Print("heiken_ashi_tf1 loaded..."); // in heiken_ashi_tf2 output is heiken_ashi_tf2 loaded, both are shown
}

....
the problem is...

it loads only one heiken ashi, if i change the timeframe sometimes it shows both subwindows but with the same timeframe...

when both are shown, ich see in indikator shotname on my desktop that in subwindow 2 is heiken_ashi_tf1 an in subwindow 3 heiken_ashi_tf2 but both are the same, theres noch difference...

and it loads most time only one subwindow, handle gives no error...

any idea?
Heiken-Ashi
  • votes: 10
  • 2010.01.26
  • MetaQuotes Software Corp. | English Russian Chinese Spanish Portuguese
  • www.mql5.com
The Heiken-Ashi indicator is looks like the candlestick chart, but it has some difference.The advantage of the Heiken-Ashi charts is a simple trend determination, the upward trend candles are blue,the downward trend candles are red.
Reason: