一些MT4代碼需要建議
Results 1 to 5 of 5

Thread: 一些MT4代碼需要建議

  1. #1
    你好
    我有以下代碼,試圖通過計算當前柱的Close-Low來製作MA。我的主要問題是:

    當我第一次放置室內時,它被畫得很好。但在它之後它開始畫一條直線......不能真正找出原因。

    我已經知道這個錯誤是我得到的兩個while循環的原因,它與蠟燭變量有關。如果我將歷史變量替換while循環中的蠟燭變量,那麼它可以正常工作,但通過這樣做,它將一次又一次地重新繪製所有條形圖。

    任何想法/建議?

    這是代碼

    插入的代碼#include lt; stderror.mqhgt; #include lt; stdlib.mqhgt; #property indior_level1 0 #property indior_separate_window/#property indior_chart_window/Indior在主窗口中繪製#property indior_buffers 2 #property indior_color1白色//#property indior_color2藍色//---緩衝區雙Buf_0#91;#93 ;;/--- parameters extern int history = 3000; extern bool log_on = false; extern int MAperiod = 14;/extern bool separate_window = true; string build = ver 0.29g-TEST-MA; bool isHistoryLoading; int lastperiod = 0; int init(){isHistoryLoading = true; SetIndexStyle(0,DRAW_LINE,DRAW_SECTION,2); SetIndexBuffer(0,Buf_0); SetIndexLabel(0,MA); IndiorShortName(MA( MAperiod ) build); SetLevelValue(0,0.0000);/水平線水平設置為return(0); } int deinit(){return(0); } int start(){double ARM = 0,barARM = 0,ASB = 0;雙O,C,H,L; datetime dt,mdt,dt1,dtTemp; int i,j,k,candles,counted_bars;/int btbars = backtest_bars; double Buffer#91; 10000#93 ;; if(isHistoryLoading){dt = iTime(Symbol(),PERIOD_M1,0); if(dt == 0){isHistoryLoading = true; return;} isHistoryLoading = false; counted_bars = 0; } else counts_bars = IndiorCounted(); if(candleslt; 0)返回(0);蠟燭=棒材 - counted_bars;/第一個不計數的索引(candlesgt; history-1)//如果太多吧... {candles = history-1;/..計算指定數量}/*********************************主循環**** ************************ while((ilt; =蠟燭)){L =低#91;我#93 ;; C =關閉#91 ; I#93 ;; ARM = ARM C-L; wlog(我改變了我#91; i #93;);緩衝區#91; i#93; = ARM;/在單獨的窗口wlog上繪製indior(緩衝區#91; i #93; = Buf_0#91; i#93;);我 ; ARM = 0; }/END年int vi = 0; double sum = 0.0; while(vilt; =蠟燭)//CALCULATE MA {vi ; for(int vk = vi; vklt; vi MAperiod; vk ){sum = sum Buffer#91; vk#93 ;; }/for sum = sumMAperiod; Buf_0#91; vi#93; = sum;/;總和= 0; }/while return(0); } void wlog(string s){if(log_on){Print(s); }}

  2. #2

  3. #3

    Quote Originally Posted by ;
    回復發佈在mql4論壇上
    看起來它仍然重新粉刷了最後幾個酒吧。因為如果稍後重新編譯它會以不同的方式繪製(最後幾個條)。

  4. #4
    我已經重寫了代碼(相當)...我認為它的工作原理應該如此。它也為當前的酒吧繪畫,我認為這是一件好事。插入代碼#property indior_separate_window #property indior_level1 0 #property indior_buffers 1 #property indior_color1 Red double Buf_0#91;#93 ;; extern int history = 3000; extern int period = 14; int i,p; void init(){SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Buf_0); SetIndexLabel(0,MA); IndiorShortName(MA( period )); SetLevelValue(0,0.0000); while(Bars lt; history)Sleep(100); p =歷史時期; Buf_0 = 0; for(i = history-1; i gt; = p; i--)Buf_0 = Close#91; i#93; - 低#91;我#93 ;; Buf_0=期間; for(i = p-1; i gt; = 0; i--)Buf_0#91; i#93; =(Buf_0#91; i 1#93; *週期 - (關閉#91; i 期間#93; - 低#91; i 期間#93;) (關閉#91; i#93; - 低#91;我#93;))/期間; } void start(){Buf_0#91; 0#93; =(Buf_0#91; 1#93; *週期 - (關閉#91;期間#93; - 低#91;期間#93;) (關閉#91; 0#93; - 低#91; 0#93 ;))/期間; }

  5. #5
    是的,也是如此...我從來沒有這樣使用init。謝謝
    Quote Originally Posted by ;
    我已經重寫了代碼(相當)...我認為它的工作原理應該如此。它也為當前的酒吧繪畫,我認為這是一件好事。 [code] #property indior_separate_window #property indior_level1 0 #property indior_buffers 1 #property indior_color1 Red double Buf_0 []; extern int history = 3000; extern int period = 14; int i,p; void init(){SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Buf_0); SetIndexLabel(0,MA); IndiorShortName(MA( period )); SetLevelValue ...
    Quote Originally Posted by ;
    我已經重寫了代碼(相當)...我認為它的工作原理應該如此。它也為當前的酒吧繪畫,我認為這是一件好事。 [code] #property indior_separate_window #property indior_level1 0 #property indior_buffers 1 #property indior_color1 Red double Buf_0 []; extern int history = 3000; extern int period = 14; int i,p; void init(){SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Buf_0); SetIndexLabel(0,MA); IndiorShortName(MA( period )); SetLevelValue ...

發布權限

  • 您不可發布新主題
  • 您不可回复
  • 您不可發布附件
  • 您不可編輯您的帖子
  •  
  • BB代碼是打開的
  • 表情符號是打開的
  • [IMG]代碼是打開的
  • [視頻]代碼是打開的
  • HTML代碼是關閉的
forex-pedia網站使用cookie 文字跟蹤
forex-pedia.com網站使用cookie 文字跟蹤,某些設定已經固定。您可以點擊此處閱讀我們的Cookie使用說明。 請點擊右鍵接受我們的cookies。如果您選擇繼續使用forex-pedia.com網站,我們將認為您接受我們的cookies。