MT4斐波那契指标修改版源码,Fibonacci Modified 指标完整源码


原理: 参考斐波那契通过原理公式绘出指标

点击下载程序与源码 文件大小:2.21 KB

必须读我.txt 策汇在线.url MQL4/ MQL4/Indicators/ MQL4/Indicators/Fibonacci Modified.mq4

MQL4/Indicators/Fibonacci Modified.mq4代码片段:

 //+------------------------------------------------------------------+ //| 斐波那契 修改版 | //| Copyright 2020.策汇在线 http://www.fxchs.com | //| http://www.fxchs.com | //+------------------------------------------------------------------+ // 主图表显示 #property indicator_chart_window // 缓存 #property indicator_buffers 4 // 严格编译 600版本以后必须 #property strict // 定义上中下轨线颜色 #property indicator_color1 Silver #property indicator_color2 White #property indicator_color3 Red #property indicator_color4 Pink // 缓存变量 double HighBuffer[]; double LowBuffer[]; double MedianBuffer[]; double Fib618[]; extern int BarsCount=100; // 计算高低价柱面数量 //////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // 介绍: 斐波那契 修改版 // // 原理: 参考斐波那契通过原理公式绘出指标 // // 来自: 策汇在线: http://www.fxchs.com // // /////////////////////////////////////////////////////////////////////////////////////////////////////////// //+------------------------------------------------------------------+ //| 初始化 | //+------------------------------------------------------------------+ int init() { // 指标上中下轨缓存 IndicatorBuffers(4); SetIndexBuffer(0,HighBuffer); SetIndexBuffer(1,MedianBuffer); SetIndexBuffer(2,LowBuffer); SetIndexBuffer(3,Fib618); // 线条风格 SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); // 线条标签 SetIndexLabel(0,"High"+ IntegerToString(BarsCount)); SetIndexLabel(1,"Median"+IntegerToString(BarsCount)); SetIndexLabel(2,"Low"+IntegerToString(BarsCount)); SetIndexLabel(3,"61.8"); // 指标名称 string shortname="Fibonacci Modified"; IndicatorShortName(shortname); // 精度 IndicatorDigits(Digits); return(0); } //+------------------------------------------------------------------+ //| 入口 | //+------------------------------------------------------------------+ int start() { int limit; // 得到需要绘制Fibo的K线柱面数 int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; // 得到数据送入缓存,会自动刷新图表 for(int i=0; i<limit; i++) { // 上轨取的最高价 HighBuffer[i]=High[iHighest(NULL,0,MODE_HIGH,BarsCount,i)]; // 中轨取的均价 MedianBuffer[i]=(HighBuffer[i]+LowBuffer[i])/2; // 下轨最低价 LowBuffer[i]=Low[iLowest(NULL,0,MODE_LOW,BarsCount,i)]; // Fibo黄金分割 上轨 - (上轨 - 下轨) * 0.618 Fib618[i]=HighBuffer[i]-(HighBuffer[i]-LowBuffer[i])*0.618; } return(0); } //+------------------------------------------------------------------+