[i]SilverTrend_Ron_MT4_v02_v1

Author: SilverTrend rewritten by CrazyChart
[i]SilverTrend_Ron_MT4_v02_v1
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
[i]SilverTrend_Ron_MT4_v02_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//| SilverTrend_Signal.mq4 
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property copyright "SilverTrend  rewritten by CrazyChart"
#property link      "http://viac.ru/"
// mods my Ron Thompson April 2006
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Magenta
 
//---- input parameters
extern int RISK=3;
extern int CountBars=1500;
extern int SSP=9;
extern bool UseClose=true;
 
//---- buffers
double val1[];
double val2[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
   
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,val1);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,val2);
  }
  
//+------------------------------------------------------------------+
//| SilverTrend_Signal                                               |
//+------------------------------------------------------------------+
int start()
  {   
   
   int i, i1, shift;
   
   double Range,AvgRange,smin,smax,SsMax,SsMin;
   
   bool uptrend,old;
  
   for (shift=CountBars; shift>=0; shift--) 
     { 
      Range=0;
      AvgRange=0;
      
      // Calculate Hi/Lo average for last SSP periods
      for (i1=shift; i1<=shift+SSP; i1++)
        {
         AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
        }
      Range=AvgRange/(SSP+1);
 
      // find highest high and lowest low SSP periods back
      SsMax=High[Highest(Symbol(),0,MODE_HIGH,SSP,shift)];
      SsMin= Low[Lowest (Symbol(),0,MODE_LOW ,SSP,shift)];
 
      smin = (SsMin+(((SsMax-SsMin)*(33-RISK))/100));
      smax = (SsMax-(((SsMax-SsMin)*(33-RISK))/100));
   
      if(UseClose)
       {
        if (Close[shift]<smin) uptrend = false;
        if (Close[shift]>smax) uptrend = true;
       }
      else
       {
        if (Open[shift]<smin) uptrend = false;
        if (Open[shift]>smax) uptrend = true;
       }
   
      if (uptrend!=old && uptrend==true)
        {
         val1[shift]=Low[shift]-Range*1.2;
         val2[shift]=0;
        }

      if (uptrend!=old && uptrend==false) 
        {
         val1[shift]=0;
         val2[shift]=High[shift]+Range*1.2;
        }

      old=uptrend;
 
     }//for
  
  }//start
  

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 ---