Preference question

 

My spelling sucks today!  :P

Do you like to have indicators in the same window with your candlesticks/bars?  Or do like to have them in a separate windows to avoid "clutter"?  I'm writing a family of indicators and am stuck on this "philosophical" question.  (Again, bad spelling.).

 

It is not always the case of preference as many indicators ONLY make sense if on one or the other. For example:

  • Oscillators only make sense to be on a sub window.
  • Fractals and ZigZag only makes sense on the Main window.
  • etc.

Either way, in terms of coding, they are exactly the same, and only a single program property makes the difference, namely one of the following:

  • "#propery indicator_chart_window"
  • "#propery indicator_separate_window"

That being said, you don't have to worry about your "philosophical dilemma". You can easily achieve both!

So, where an Indicator is valid and makes sense for both situations, you can easily have a common include file (".mqh" with the full indicator code), and the two differentiating versions (".mq4" with only the appropriate property setting), in order to have both available.

 
FMIC:

It is not always the case of preference as many indicators ONLY make sense if on one or the other. For example:

  • Oscillators only make sense to be on a sub window.
  • Fractals and ZigZag only makes sense on the Main window.
  • etc.

Either way, in terms of coding, they are exactly the same, and only a single program property makes the difference, namely one of the following:

  • "#propery indicator_chart_window"
  • "#propery indicator_separate_window"

That being said, you don't have to worry about your "philosophical dilemma". You can easily achieve both!

So, where an Indicator is valid and makes sense for both situations, youcan easily have a common include file (".mqh" with the full indicator code), and the two differentiating versions (".mq4" with only the appropriate property setting), in order to have both available.

Thanks.  What I'm working on can go both ways. 

So, I guess I should re-word my question:

If you have a choice as to where you would like an indicator to display, which would it be?  Main window where the candlesticks/bars are or a sub window?  This question is still for everyone.

 
nondisclosure: Thanks.  What I'm working on can go both ways. So, I guess I should re-word my question:

If you have a choice as to where you would like an indicator to display, which would it be?  Main window where the candlesticks/bars are or a sub window?  This question is still for everyone.

As I stated! You don't need to restrict it to just one or the other! You can code the indicator so that the user can choose!

Write all the code as an Include/Header file (".mqh") and have two files with just a couple of lines (an "#include" and a "#property"), where one file set up as for the main chart window and another as a separate window (see previous post and code below).

This way you only code once, but supply both versions, leaving the choice for the user - hence there is no "philosophical dilemma" (see example skeleton code below):

"MyIndicator.MainChart.mq4" File (placed in "Indicators" folder) for displaying on Main Chart Window :

// Display on Main Chart Window
#property indicator_chart_window
#include <MyIndicator.mqh>

"MyIndicator.Separate.mq4" File (placed in "Indicators" folder) for displaying on Separate Chart Window:

// Display on Separate Chart Window
#property indicator_separate_window
#include <MyIndicator.mqh>

"MyIndicator.mqh" File (placed in "Include" folder) for common Custom Indicator code to be included in both previous files:

// Main Custom Indicator Code
#property strict
#property indicator_buffers          1
#property indicator_width1           1
#property indicator_style1           STYLE_SOLID
#property indicator_type1            DRAW_LINE
#property indicator_color1           clrYellow

int OnInit()
{
   //--- indicator buffers mapping
   return(INIT_SUCCEEDED);
}

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[])
{
   //--- return value of prev_calculated for next call
   return(rates_total);
}

PS! If you need specific compile time differentiation in the code, just use a separate/different "#define" in each of the ".mq4" files and then use conditional compilation in the ".mqh" header file.

 
FMIC:

As I stated! You don't need to restrict it to just one or the other! You can code the indicator so that the user can choose!

Write all the code as an Include/Header file (".mqh") and have two files with just a couple of lines (an "#include" and a "#property"), where one file set up as for the main chart window and another as a separate window (see previous post and code below).

This way you only code once, but supply both versions, leaving the choice for the user - hence there is no "philosophical dilemma" (see example code below):

"MyIndicator.MainChart.mq4" File (placed in "Indicators" folder) for displaying on Main Chart Window :

"MyIndicator.Separate.mq4" File (placed in "Indicators" folder) for displaying on Separate Chart Window:

"MyIndicator.mqh" File (placed in "Include" folder) for common Custom Indicator code to be included in both previous files:

PS! If you need specific compile time differentiation in the code, just use a separate/different "#define" in each of the ".mq4" files and then use conditional compilation in the ".mqh" header file.

Thanks for all the info FMIC.  I am already doing what you state.  You're right.  I can just supply both versions then.  :)
Reason: