T.S.V._Bullish & Bearish

Author: Sergey_T.S.V.
T.S.V._Bullish & Bearish
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
2 Views
0 Downloads
0 Favorites
T.S.V._Bullish & Bearish
//+------------------------------------------------------------------+
//|                                     T.S.V._Bullish & Bearish.mq4 |
//|                                                    Sergey_T.S.V. |
//|                                                       &&&&&&&&&& |
//+------------------------------------------------------------------+
#property copyright "Sergey_T.S.V."
#property  indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  Blue
#property indicator_color2 Red
#property indicator_color3 ForestGreen
extern int period=1;int CountBars=3000;
double ExtBuffer0[];double ExtBuffer1[];double ExtBuffer2[];double Up[];double Down[];
int init(){
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4,Red);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4,ForestGreen);IndicatorDigits(Digits+1);
   SetIndexBuffer(0,ExtBuffer0);SetIndexBuffer(1,ExtBuffer1);SetIndexBuffer(2,ExtBuffer2);
   SetIndexBuffer(1,Up);SetIndexBuffer(2,Down);SetIndexLabel(1,NULL);SetIndexLabel(2,NULL); 
   return(0);}
int start(){
   SetIndexDrawBegin(1,Bars-CountBars+period);SetIndexDrawBegin(2,Bars-CountBars+period);
   int i,counted_bars=IndicatorCounted();bool Pr=false,PrevPr=false;double val,val2;
   if(CountBars<=period)return(0);if(counted_bars<1){ for(i=1;i<=period;i++)Up[CountBars-i]=0.0;
   for(i=1;i<=period;i++)Down[CountBars-i]=0.0;}i=CountBars-period-1;while(i>=0){
   val=iMA(NULL,0,period,1,MODE_SMA,PRICE_HIGH,i);val2=iMA(NULL,0,period,1,MODE_SMA,PRICE_LOW,i);
   if (Close[i]<val2 && PrevPr==true)Pr=false;if (Close[i]>val && PrevPr==false)Pr=true;
   PrevPr=Pr;Up[i]=0.0;Down[i]=0.0;if (Pr==false)Up[i] = val+2*Point; 
   if (Pr==true)Down[i] = val2-2*Point; i--; } 
   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 ---