#MFT_STLM2_v2

Here's a breakdown of what this MetaTrader script does, explained in a way that doesn't require programming knowledge:

This script is designed to display a special type of indicator called "STLM2" on your chart. However, it does something more advanced than just showing the standard STLM2.

Imagine you're looking at a stock price chart that shows data for each day. This script lets you see what the STLM2 indicator would look like if it were calculated on a longer timeframe than the one you're currently viewing. For example, you might be looking at a chart showing price changes every hour, but you want to see the STLM2 indicator calculated using daily data.

Here's how it achieves this:

  1. Choosing the Timeframe: The script has a setting where you can choose the longer timeframe you want to use for the STLM2 calculation (e.g., daily, weekly).

  2. Retrieving STLM2 Values: The script then goes through the historical data on your current chart. For each point in time on your chart, it finds the corresponding STLM2 value that would have been calculated on the chosen longer timeframe. It uses the "STLM2" indicator as the base for calculation.

  3. Displaying the Information: Finally, the script draws two histograms (like bar charts) on a separate window below your main price chart. One histogram represents the "Up" values of the STLM2 indicator and the other represents the "Down" values, each using the longer timeframe you selected. This allows you to see the STLM2 indicator's trend on a bigger scale, even while looking at a shorter-term chart.

2 Views
0 Downloads
0 Favorites
#MFT_STLM2_v2
//+------------------------------------------------------------------+
//|                            MTF_STLM2_v2.mq4 
//| by Zathar Modified by Simba
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Aqua
#property indicator_width1 2
#property indicator_width2 2

extern int TimeFrame=1440;
double ExtMapBuffer1[];
double ExtMapBuffer2[];


int init()
  {
   //---- indicator line
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);   
   IndicatorShortName("MTF_STLM2_v2");
   SetIndexLabel(0,"Up");
   SetIndexLabel(1,"Dn");

  }
//----
   return(0);
 

int start()
  {
   datetime TimeArray[];
   int    i,shift,limit,y=0,counted_bars=IndicatorCounted();
     
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++) {
     if (Time[i]<TimeArray[y]) {y++;}   
     ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"STLM2",1,y); 
     ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"STLM2",0,y);
   }
   return(0);
  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---