PDA

View Full Version : 第一次尝试



kimohg88
03-16-2009 14:20, 02:20 PM
我有其他平台的编程经验,但这是我第一次尝试metatrader和基于C 的语言,我需要一些帮助。我想从一个简单的指标开始,在一张图表上绘制不同时间范围的最高和最低点。代码编译但添加到图表时没有绘制:

插入代码#属性版权互联网#属性链接#属性indior_chart_window #property indior_buffers 4/----输入参数extern int timeframe1 = 15; extern int timeframe2 = 240;/---指标缓冲区double ExtMapBuffer1#91;#93 ;; double ExtMapBuffer2#91;#93 ;; double ExtMapBuffer3#91;#93 ;; double ExtMapBuffer4#91;#93 ;;/ ----------------------------------------------- ------------------- /|自定义指标初始化函数|/ ----------------------------------------------- ------------------- int init(){//----指标缓冲区映射SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(3,DRAW_LINE);* ----创建矩形指标ObjectCreate(sObjName,OBJ_RECTANGLE,0,0,0,0,0); ObjectSet(sObjName,OBJPROP_STYLE,STYLE_SOLID); ObjectSet(sObjName,OBJPROP_COLOR,cObjColor); ObjectSet(sObjName,OBJPROP_BACK,bProp_Back); *return(0); }/ ---------------------------------------------- -------------------- /|自定义指标取消初始化函数|/ ----------------------------------------------- ------------------- int deinit(){//----/---- return(0); }/ ---------------------------------------------- -------------------- /|自定义指标迭代函数|/ ----------------------------------------------- ------------------- int start(){int counting_bars = IndiorCounted(); int limit; int pos = 0;双高T1;双低T1;双高T2;双低T2;/----计算图表上的条数的脚本if(counts_barslt; 0)return(-1); if(counts_barsgt; 0)counting_bars--;极限=棒材 - counted_bars;/---- Main Code for(int i = 0; ilt; = timeframe1; i ){if(High#91; i#93; gt; highT1)highT1 = High#91; i#93 ;; (低#91; i#93; lt; lowT1)lowT1 =低#91; i#93 ;; } for(int j = 1; jlt; = timeframe2; j ){if(High#91; j#93; gt; highT2)highT2 = High#91; j#93 ;; (Low#91; j#93; lt; lowT2)lowT2 = Low#91; j#93 ;; } for(pos = Bars; pos gt; = 0; pos--){ExtMapBuffer1#91; pos#93; = highT1; ExtMapBuffer2#91;#POS 93; = lowT1; ExtMapBuffer3#91;#POS 93; = highT2; ExtMapBuffer4#91;#POS 93; = lowT2; } return(0); }/ ---------------------------------------------- --------------------