KawaseOsyo_StochasticHistogram

Author: Copyright By KawaseOsyo,TransEdge co.,Ltd.
KawaseOsyo_StochasticHistogram
Indicators Used
Stochastic oscillator
0 Views
0 Downloads
0 Favorites
KawaseOsyo_StochasticHistogram
//+------------------------------------------------------------------+
//|                                KawaseOsyo_StochasticHistgram.mq4 |
//|                 Copyright © 2011, KawaseOsyo, Syotaro Yoshida    |
//|                                       http://www.kawaseosyo.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright By KawaseOsyo,TransEdge co.,Ltd."
#property link      "http://www.kawaseosyo.com/"

#property indicator_separate_window
#property indicator_buffers   4
#property indicator_color1 Orange
#property indicator_color2 White
#property indicator_color3 RoyalBlue
#property indicator_color4 Red
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
#property indicator_style3 STYLE_SOLID
#property indicator_style4 STYLE_SOLID
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3


// ¡¡¡ ƒŒƒxƒ‹ƒ‰ƒCƒ“
#property indicator_levelcolor DarkGray
#property indicator_maximum  100
#property indicator_minimum -100

#define   OVER_BOUGHT 50
#define   OVER_SOLD   50

// ¡¡¡ ƒpƒ‰ƒ[ƒ^
extern string URL = "www.kawaseosyo.com";
extern int  KPeriod    = 14;        // %K
extern int  DPeriod    =  3;        // %D
extern int  Slowing    =  3;        // Slow Stochastic

// ¡¡¡ ƒoƒbƒtƒ@
double m_factorK[];
double m_factorD[];
double m_up[];
double m_down[];

// ¡¡¡¡¡¡¡¡¡ ‰ŠúÝ’è ¡¡¡¡¡¡¡¡¡

int init()
{
    // ¡¡¡ ƒoƒbƒtƒ@Ý’è
    SetIndexBuffer( 0, m_factorK ); // %K
    SetIndexBuffer( 1, m_factorD ); // %D    
    SetIndexBuffer( 2, m_up );      // Up
    SetIndexBuffer( 3, m_down );    // Down    
    
    // ¡¡¡ •`‰æ
    SetIndexStyle ( 0, DRAW_NONE      );// %K
    SetIndexStyle ( 1, DRAW_NONE      );// %D
    SetIndexStyle ( 2, DRAW_HISTOGRAM );// Stochastic Up  (%K)
    SetIndexStyle ( 3, DRAW_HISTOGRAM );// Stochastic Down(%K)

    SetIndexLabel ( 0, "%K" );
    SetIndexLabel ( 1, "%D" );
    SetIndexLabel ( 2, "Stochastic Up");
    SetIndexLabel ( 3, "Stochastic Down");
    
    // ¡¡¡ ƒCƒ“ƒWƒP[ƒ^–¼Ý’è
    string shortName = "KawaseOsyo Stochastic Histogram(" + KPeriod +","+ DPeriod +","+ Slowing +")";      
    return(0);
}


// ¡¡¡¡¡¡¡¡¡ ƒƒCƒ“ˆ— ¡¡¡¡¡¡¡¡¡

int start()
{
int limit = Bars - IndicatorCounted();

    if(IndicatorCounted()<0) return(-1);

    // ¡¡¡ ƒXƒgƒLƒƒƒXŒvŽZ
    for( int j=limit ; j>=0 ; j--){
        m_factorK[j] = iStochastic( NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 1, MODE_MAIN,  j);
        m_factorD[j] = iStochastic( NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 1, MODE_SIGNAL,j);
    }

    // ¡¡¡ ƒXƒgƒLƒƒƒX‚̐F‚¯
    for( int i=limit ; i>=0; i--){
        m_up[i]=EMPTY_VALUE;
        m_down[i]=EMPTY_VALUE;
    
        // ¡¡¡ ƒAƒbƒvƒgƒŒƒ“ƒh
        if( m_factorK[i] > OVER_BOUGHT ){
            m_up[i] = GetValue(m_factorK[i]);
        }
    
        // ¡¡¡ ƒ_ƒEƒ“ƒgƒŒƒ“ƒh
        if( m_factorK[i] < OVER_SOLD ){
            m_down[i] = GetValue(m_factorK[i]);

        }
    }    
    return(0);
}

// ¡¡¡¡¡¡¡¡¡ ƒXƒgƒLƒƒƒX‚̐”’l•ÏŠ· ¡¡¡¡¡¡¡¡¡

double GetValue( double value )
{
    return( (value-OVER_BOUGHT)*2.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 ---