วิธีการเพิ่มสีเขียวสีแดงบน histogram?
Results 1 to 6 of 6

Thread: วิธีการเพิ่มสีเขียวสีแดงบน histogram?

  1. #1
    1 Attachment (s) สวัสดีเพื่อน ๆ ,

    ฉันไม่ใช่ผู้เชี่ยวชาญ coder และสับสนเกี่ยวกับวิธีการเพิ่มสีเขียวสำหรับ histogram บวกและสีแดงสำหรับ histogram ค่าลบในตัวบ่งชี้นี้


    รหัสตัวบ่งชี้:
    แทรกรหัส/ --------------------------------------------- --------------------- /| CandleAverage_v1.mq4 |/| สงวนลิขสิทธิ์© 2006, Forex-TSD.com |/| เขียนโดย IgorAD, igorad2003 @ yahoo.co.uk |/| http://finance.groups.yahoo.com/group/TrendLaboratory |/ ----------------------------------------------- ------------------- # property copyright © 2006, Forex-TSD.com # คุณสมบัติลิงค์ http://www.forex-tsd.com/#property_separate_window #property indior_buffers 1 #property indior_color1 DeepSkyBlue/---- ใส่พารามิเตอร์ extern int ความยาว = 31; int ภายนอก H_period = 25; extern int L_period = 27; extern int C_period = 9;/---- บัฟเฟอร์คู่ CandleAvg # 91; # 93 ;; คู่ BarValue # 91; # 93 ;;/ ----------------------------------------------- ------------------- /| ฟังก์ชันการเริ่มต้นตัวบ่งชี้ที่กำหนดเอง |/ ----------------------------------------------- ------------------- int init () {//---- indior IndiorBuffers (2); SetIndexStyle (0, DRAW_HISTOGRAM); SetIndexBuffer (0, CandleAvg); SetIndexBuffer (1, BarValue);/---- ชื่อสำหรับ DataWindow และตัวบ่งชี้ subwindow ป้ายชื่อสตริง short_name = CandleAverage ( ความยาว ); IndiorShortName (SHORT_NAME); SetIndexLabel (0, CandleAvg); SetIndexDrawBegin (0, ความยาว);/---- return (0); }/ ---------------------------------------------- -------------------- /| ฟังก์ชันย้ำตัวบ่งชี้ที่กำหนดเอง |/ ----------------------------------------------- ------------------- int เริ่มต้น () {int shift, limit, counted_bars = IndiorCounted (); ดับเบิล UpDel, DnDel, H, L, C;/---- if (counted_barslt; 0) return (-1); ถ้า (counted_bars == 0) วงเงิน = บาร์ - ยาว -1;/---- ล่าสุดนับแถบจะ recounted if (counted_barsgt; 0) limits = Bars-counted_bars; limit--; สำหรับ (shift = limit; shiftgt; = 0; shift--) {H = iMA (NULL, 0, H_period, 0, MODE_EMA, PRICE_HIGH, shift); L = iMA (NULL, 0, L_period, 0, MODE_EMA, PRICE_LOW, shift); C = iMA (NULL, 0, C_period, 0, MODE_EMA, PRICE_CLOSE, shift); UpDel = H - C; DnDel = C - L; if (UpDel lt; DnDel) BarValue # 91; shift # 93; = 1; if (UpDel gt; DnDel) BarValue # 91; shift # 93; = -1; if (UpDel == DnDel) BarValue # 91; shift # 93; = 0; } for (shift = limit; shiftgt; = 0; shift--) {CandleAvg # 91; shift # 93; = iMAOnArray (BarValue, 0, ความยาว, 0, MODE_SMA, shift); }/---- return (0); }/ ---------------------------------------------- -------------------- ฉันพยายามเปลี่ยนรหัสเช่นร้อง:

    แทรกรหัส # property indior_separate_window # property indior_buffers 2 #property_color1 DeepSkyBlue #property_color2 สีแดง แต่ไม่ได้ผลเนื่องจากค่า histogram เก็บไว้เฉพาะในบัฟเฟอร์ 1 อัน CandleAvg

    วิธีการแยกค่าบวกและลบจากบัฟเฟอร์ CandleAvg และเพิ่มสีเขียวแดง?

    กรุณาแนะนำ.

    ขอขอบคุณสำหรับความช่วยเหลือ






  2. #2
    เพิ่มบัฟเฟอร์อีกสองชุด: CandleAvgPlus [] และ CandleAvgMinus [] และตั้งค่าให้ว่างเปล่า จากนั้นใช้คำสั่ง if ในห่วง for เพื่อเติมบัฟเฟอร์ใหม่สองชุดนี้ .. if (CandleAvg [i] gt; = somenumber) CandleAvgPlus [i] = CandleAvg [i]; if (CandleAvg [i] lt; somenumber) CandleAvgMinus [i] = CandleAvg [i]; ตอนนี้เพียงพล็อต CandleAvgPlus และ CandleAvgMinus แทน CandleAve เห็นได้ชัดว่าพวกเขาประกาศอย่างถูกต้องและเริ่มต้นได้อย่างถูกต้อง แต่นี่เป็นเทคนิคในการแยกพวกเขาออกโดยที่ฉันจริงเขียนโค้ดสำหรับคุณด้านล่าง ในบันทึกอื่นผมได้เรียนรู้มากที่สุดของการเขียนโปรแกรมของฉันเพียงแค่ดูที่รหัสจากคนอื่น ๆ ในกรณีนี้ไฟล์ mq4 บน MACD สีจะแสดงสิ่งที่ทั้งตัวให้คุณเป็นจริงอย่างรวดเร็ว

  3. #3

    Quote Originally Posted by ;
    เพิ่มบัฟเฟอร์อีกสองชุด: CandleAvgPlus [] และ CandleAvgMinus [] และตั้งค่าให้ว่างเปล่า จากนั้นใช้คำสั่ง if ในห่วง for เพื่อเติมบัฟเฟอร์ใหม่สองชุดนี้ .. if (CandleAvg [i] gt; = somenumber) CandleAvgPlus [i] = CandleAvg [i]; if (CandleAvg [i] lt; somenumber) CandleAvgMinus [i] = CandleAvg [i]; ตอนนี้เพียงพล็อต CandleAvgPlus และ CandleAvgMinus แทน CandleAve เห็นได้ชัดว่าพวกเขาประกาศอย่างถูกต้องและเริ่มต้นได้อย่างถูกต้อง แต่นี่เป็นเทคนิคในการแยกพวกเขาออกโดยที่ฉันจริงเขียนโค้ดสำหรับคุณด้านล่าง ในบันทึกอื่นที่ฉันได้เรียนรู้มากที่สุด ...
    ขอขอบคุณสำหรับใบปลิวความช่วยเหลือ 345 ขอขอบคุณสำหรับความประสงค์ของคุณในการเขียนโค้ดสำหรับฉัน แต่ฉันต้องการเขียนใหม่ด้วยตนเองและเรียนรู้จากสิ่งนี้ ฉันเป็นคนใหม่เกี่ยวกับการเข้ารหัส MQL และยังต้องเรียนรู้เป็นอย่างมาก ฉันพยายามทำตามคำแนะนำและแก้ไขโค้ด แต่ไม่ได้ผล ฉันพยายามเป็นเวลาหลายชั่วโมงแล้วและไม่ทราบว่าทำไมถึงไม่ทำงาน แทรกรหัส/ --------------------------------------------- --------------------- /| CandleAverage_v1.mq4 |/| สงวนลิขสิทธิ์© 2006, Forex-TSD.com |/| เขียนโดย IgorAD, igorad2003 @ yahoo.co.uk |/| http://finance.groups.yahoo.com/group/TrendLaboratory |/ ----------------------------------------------- ------------------- # property copyright © 2006, Forex-TSD.com # คุณสมบัติลิงค์ http://www.forex-tsd.com/#property_separate_window #property indior_buffers 4 #property indior_color1 DeepSkyBlue #property indior_color3 กรีน # คุณสมบัติตัวบ่งชี้_color4พารามิเตอร์สีแดง/---- ป้อนค่า int ยาว = 31; int ภายนอก H_period = 25; extern int L_period = 27; extern int C_period = 9;/---- บัฟเฟอร์คู่ CandleAvg # 91; # 93 ;; คู่ BarValue # 91; # 93 ;; คู่ CandleAvgPlus # 91; # 93 ;; คู่ CandleAvgMinus # 91; # 93 ;;/ ----------------------------------------------- ------------------- /| ฟังก์ชันการเริ่มต้นตัวบ่งชี้ที่กำหนดเอง |/ ----------------------------------------------- ------------------- int init () {//---- indior IndiorBuffers (4); SetIndexStyle (0, DRAW_NONE); SetIndexStyle (1, DRAW_NONE); SetIndexStyle (2, DRAW_HISTOGRAM); SetIndexStyle (3, DRAW_HISTOGRAM); SetIndexBuffer (0, CandleAvg); SetIndexBuffer (1, BarValue); SetIndexBuffer (2, CandleAvgPlus); SetIndexBuffer (3, CandleAvgMinus);/---- ชื่อสำหรับ DataWindow และตัวบ่งชี้ subwindow ป้ายชื่อสตริง short_name = CandleAverage ( ความยาว ); IndiorShortName (SHORT_NAME); SetIndexLabel (0, CandleAvg); SetIndexDrawBegin (0, ความยาว);/---- return (0); }/ ---------------------------------------------- -------------------- /| ฟังก์ชันย้ำตัวบ่งชี้ที่กำหนดเอง |/ ----------------------------------------------- ------------------- int เริ่มต้น () {int shift, limit, counted_bars = IndiorCounted (); ดับเบิล UpDel, DnDel, H, L, C;/---- if (counted_barslt; 0) return (-1); ถ้า (counted_bars == 0) วงเงิน = บาร์ - ยาว -1;/---- ล่าสุดนับแถบจะ recounted if (counted_barsgt; 0) limits = Bars-counted_bars; limit--; สำหรับ (shift = limit; shiftgt; = 0; shift--) {H = iMA (NULL, 0, H_period, 0, MODE_EMA, PRICE_HIGH, shift); L = iMA (NULL, 0, L_period, 0, MODE_EMA, PRICE_LOW, shift); C = iMA (NULL, 0, C_period, 0, MODE_EMA, PRICE_CLOSE, shift); UpDel = H - C; DnDel = C - L; if (CandleAvg # 91; shift # 93; gt; = UpDel) CandleAvgPlus # 91; shift # 93; = CandleAvg # 91; shift # 93 ;;if (CandleAvg # 91; shift # 93; lt; DnDel) CandleAvgMinus # 91; shift # 93; = CandleAvg # 91; shift # 93 ;; if (UpDel lt; DnDel) BarValue # 91; shift # 93; = 1; if (UpDel gt; DnDel) BarValue # 91; shift # 93; = -1; if (UpDel == DnDel) BarValue # 91; shift # 93; = 0; } for (shift = limit; shiftgt; = 0; shift--) {CandleAvgPlus # 91; shift # 93; = iMAOnArray (BarValue, 0, ความยาว, 0, MODE_SMA, shift); CandleAvgMinus # 91; เปลี่ยน # 93; = iMAOnArray (BarValue, 0, ความยาว, 0, MODE_SMA, shift); }/---- return (0); }/ ---------------------------------------------- -------------------- กรุณาช่วย

  4. #4
    กลับไปที่โค้ดต้นฉบับของคุณ คุณต้องอนุญาตให้ตัวบ่งชี้คำนวณ CandleAve [] ตามปกติแล้วคุณแยกค่าเป็นบวกและลบ ห่วงแรกของคุณสำหรับห่วงไม่กี่ calcs แล้วที่สองของคุณสำหรับวงเติม CandleAve [] คุณไม่จำเป็นต้องเปลี่ยนลูปเหล่านั้นเลย ตอนนี้เราต้องสร้าง loop สำหรับ loop ก่อนคำสั่ง return ที่สามสำหรับวงจะใช้ถ้างบ โดยทั่วไปถ้า CandleAve [i] gt; = 0 แล้ว CandleAvePlus [i] = CandleAve [i] อื่น CandleAveMinus [i] = CandleAve [i] โดยทั่วไปโค้ดสีเราต้องการสร้างบัฟเฟอร์ตัวบ่งชี้ตามบรรทัดฐานโดยปกติแล้วก่อนหน้าที่จะส่งคืนเราจะแยกข้อมูลออก สำหรับฉันการเข้ารหัสสีเป็นขั้นตอนสุดท้ายในตัวบ่งชี้ เพียงจุดเล็กน้อย แต่เนื่องจากคุณวางแผน CandleAvePlus และ CandleAveMinus พวกเขาควรจะ indiorbuffers 0 และ 1 จะดีกว่าวิธีอื่นที่คุณได้รับตัวเลขผสม ฯลฯ และฉันกรอกสองบัฟเฟอร์ใหม่ที่มีค่าว่างเปล่าจึงวางแผนอย่าง

  5. #5

    Quote Originally Posted by ;
    กลับไปที่รหัสเดิมของคุณ ....
    สุดท้ายมันทำงานได้อย่างสมบูรณ์ ขอบคุณสำหรับใบปลิวมากสำหรับความกรุณาของคุณและผู้ป่วยของคุณสอนฉัน ขออภัยถ้าฉันเป็นคนโง่และช้าการเรียนรู้รหัส MQL จากคุณ ขอขอบคุณอีกครั้ง นี่คือโค้ดที่แก้ไขแล้ว: โค้ดที่แทรก/ --------------------------------------- --------------------------- /| CandleAverage_v1.mq4 |/| สงวนลิขสิทธิ์© 2006, Forex-TSD.com |/| เขียนโดย IgorAD, igorad2003 @ yahoo.co.uk |/| http://finance.groups.yahoo.com/group/TrendLaboratory |/ ----------------------------------------------- ------------------- # property copyright © 2006, Forex-TSD.com # คุณสมบัติลิงค์ http://www.forex-tsd.com/#property_separate_window #property indior_buffers 4 #property indior_color1 กรีน # คุณสมบัติ indior_color2 พารามิเตอร์สีแดง/---- ใส่ค่า int ยาว = 31; int ภายนอก H_period = 25; extern int L_period = 27; extern int C_period = 9;/---- บัฟเฟอร์คู่ CandleAvgPlus # 91; # 93 ;; คู่ CandleAvgMinus # 91; # 93 ;; คู่ CandleAvg # 91; # 93 ;; คู่ BarValue # 91; # 93 ;;/ ----------------------------------------------- ------------------- /| ฟังก์ชันการเริ่มต้นตัวบ่งชี้ที่กำหนดเอง |/ ----------------------------------------------- ------------------- int init () {//---- indior IndiorBuffers (4); SetIndexStyle (0, DRAW_HISTOGRAM); SetIndexStyle (1, DRAW_HISTOGRAM); SetIndexBuffer (0, CandleAvgPlus); SetIndexBuffer (1, CandleAvgMinus); SetIndexBuffer (2, CandleAvg); SetIndexBuffer (3, BarValue);/---- ชื่อสำหรับ DataWindow และตัวบ่งชี้ subwindow ป้ายชื่อสตริง short_name = CandleAverage ( ความยาว ); IndiorShortName (SHORT_NAME); SetIndexLabel (0, CandleAvg); SetIndexDrawBegin (0, ความยาว);/---- return (0); }/ ---------------------------------------------- -------------------- /| ฟังก์ชันย้ำตัวบ่งชี้ที่กำหนดเอง |/ ----------------------------------------------- ------------------- int เริ่มต้น () {int shift, limit, counted_bars = IndiorCounted (); ดับเบิล UpDel, DnDel, H, L, C;/---- if (counted_barslt; 0) return (-1); ถ้า (counted_bars == 0) วงเงิน = บาร์ - ยาว -1;/---- ล่าสุดนับแถบจะ recounted if (counted_barsgt; 0) limits = Bars-counted_bars; limit--; สำหรับ (shift = limit; shiftgt; = 0; shift--) {H = iMA (NULL, 0, H_period, 0, MODE_EMA, PRICE_HIGH, shift); L = iMA (NULL, 0, L_period, 0, MODE_EMA, PRICE_LOW, shift); C = iMA (NULL, 0, C_period, 0, MODE_EMA, PRICE_CLOSE, shift); UpDel = H - C; DnDel = C - L; if (UpDel lt; DnDel) BarValue # 91; shift # 93; = 1; if (UpDel gt; DnDel) BarValue # 91; shift # 93; = -1; if (UpDel == DnDel) BarValue # 91; shift # 93; = 0; } for (shift = limit; shiftgt; = 0; shift--) {CandleAvg # 91; shift # 93; = iMAOnArray (BarValue, 0, ความยาว, 0, MODE_SMA, shift);} for (shift = limit; shiftgt; = 0; shift--) {if (CandleAvg # 91; shift # 93; gt; = 0) CandleAvgPlus # 91; shift # 93; = CandleAvg # 91; shift # 93 ;; if (CandleAvg # 91; shift # 93; lt; 0) CandleAvgMinus # 91; shift # 93; = CandleAvg # 91; shift # 93 ;; }/---- return (0); }/ ---------------------------------------------- --------------------

  6. #6
    [quote = wieb; 3232106] สุดท้ายมันทำงานได้อย่างสมบูรณ์ ขอบคุณมากสำหรับความกรุณาของคุณและผู้ป่วยของคุณสอนฉัน ขออภัยถ้าฉันเป็นคนโง่และช้าการเรียนรู้รหัส MQL จากคุณ ขอขอบคุณอีกครั้ง สำหรับ (shift = limit; shiftgt; = 0; shift--) {CandleAvg [shift] = iMAOnArray (BarValue, 0, ความยาว, 0, MODE_SMA, shift);* คุณสามารถใส่รหัสได้ที่นี่และบันทึกลูปถ้า (CandleAvg [shift] gt; = 0) CandleAvgPlus [shift] = CandleAvg [shift]; ถ้า (CandleAvg [shift] lt; 0) CandleAvgMinus [shift] = CandleAvg [shift]; *} ฉันได้เรียนรู้จากคนอื่นถามคำถามและมองไปที่โค้ด คุณสามารถกำจัดหนึ่งสำหรับวงตามที่แสดงในรหัสหนา ดีใจที่ได้ผล ตอนนี้คุณสามารถทำให้เครื่องบ่งชี้หลายสีเป็นแนวคิดเดียวกันได้

การขออนุญาตโพส

  • ห้ามโพสข้อความใหม่
  • ห้ามโพสตอบ
  • ห้ามแนบไฟล์
  • ห้ามแก้ไขโพส
  •  
  • รหัส BB เปิด
  • Smilies ปิด
  • รหัส [IMG] เปิด
  • รหัส [VIDEO] เปิด
  • รหัส HTML ปิด
นโยบาย Cookie
นโยบาย Cookie: เว็บไซต์ thaitradeforex มีการใช้ cookies และสำหรับการดำเนินการเยี่ยมชมเว็บไซต์ ท่านได้ยอมรับในสิ่งนี้ สำหรับข้อมูลเพิ่มเติมโปรดอ่าน 'Cookie Disclosure'.