Miscellaneous
0
Views
0
Downloads
0
Favorites
iMirror
//+------------------------------------------------------------------+
//| iMirror.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3
//---- input parameters
extern int ExtParam1;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer3);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer4);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,3);
SetIndexBuffer(2,ExtMapBuffer1);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,3);
SetIndexBuffer(3,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int First_Visible_Index=FirstVisibleBar();
int Last_Visible_Index=FirstVisibleBar()-BarsPerWindow();
if(Last_Visible_Index<0)Last_Visible_Index=0;
if(Last_Visible_Index<0)Last_Visible_Index=0;
double wr=(High[Highest(NULL,0,MODE_HIGH,First_Visible_Index-Last_Visible_Index+1,Last_Visible_Index)]-Low[Lowest(NULL,0,MODE_LOW,First_Visible_Index-Last_Visible_Index+1,Last_Visible_Index)])/Point;
for(int i=0;i<Bars;i++){
ExtMapBuffer1[i]=EMPTY_VALUE;
ExtMapBuffer2[i]=EMPTY_VALUE;
ExtMapBuffer3[i]=EMPTY_VALUE;
ExtMapBuffer4[i]=EMPTY_VALUE;
}
for(i=Last_Visible_Index;i<=First_Visible_Index;i++){
ExtMapBuffer1[i]=1/Open[i];
ExtMapBuffer2[i]=1/Close[i];
ExtMapBuffer3[i]=1/High[i];
ExtMapBuffer4[i]=1/Low[i];
}
double ho=High[Highest(NULL,0,MODE_HIGH,First_Visible_Index-Last_Visible_Index+1,Last_Visible_Index)];
double lo=Low[Lowest(NULL,0,MODE_LOW,First_Visible_Index-Last_Visible_Index+1,Last_Visible_Index)];
double hn=ExtMapBuffer4[ArrayMaximum(ExtMapBuffer4,First_Visible_Index-Last_Visible_Index+1,Last_Visible_Index)];
double ln=ExtMapBuffer3[ArrayMinimum(ExtMapBuffer3,First_Visible_Index-Last_Visible_Index+1,Last_Visible_Index)];
double RR=ho-lo;
double NR=hn-ln;
double KK=RR/NR;
for(i=Last_Visible_Index;i<=First_Visible_Index;i++){
double hh=lo+KK*(ExtMapBuffer1[i]-ln);
double ll=lo+KK*(ExtMapBuffer2[i]-ln);
ExtMapBuffer1[i]=hh;
ExtMapBuffer2[i]=ll;
if(Close[i]>Open[i]){
hh=lo+KK*(ExtMapBuffer3[i]-ln);
ll=lo+KK*(ExtMapBuffer4[i]-ln);
ExtMapBuffer4[i]=hh;
ExtMapBuffer3[i]=ll;
}
else{
ExtMapBuffer3[i]=lo+KK*(ExtMapBuffer3[i]-ln);
ExtMapBuffer4[i]=lo+KK*(ExtMapBuffer4[i]-ln);
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---