Category: Uncategorized

  • Gold Trading System with 70% win rate

    MQ4 Expert Advisor (EA) for the gold trading system described requires coding the rules in MetaEditor (MQL4). Below is a step-by-step breakdown of how to build the EA, including key logic, entry/exit conditions, and risk management.


    Step 1: Define EA Parameters (Input Variables)

    These are adjustable in the MT4 settings:

    // Input parameters
    input double LotSize = 0.1;          // Fixed lot size
    input int StopLoss = 30;            // SL in pips
    input int TakeProfit = 60;          // TP in pips (1:2 risk ratio)
    input int EMA_Fast_Period = 9;      // Fast EMA
    input int EMA_Medium_Period = 21;   // Medium EMA
    input int EMA_Slow_Period = 50;     // Slow EMA (trend filter)
    input int MinCandleSize = 10;       // Min candle size (pips) to avoid noise
    input bool UseCandlePatterns = true;// Enable candlestick patterns
    input string TradeSession = "08:00-17:00"; // London/NY session

    Step 2: Trend Filter (EMA Alignment)

    Check if EMAs are aligned for uptrend (buy) or downtrend (sell):

    bool IsUptrend() {
       double emaFast = iMA(NULL, 0, EMA_Fast_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
       double emaMedium = iMA(NULL, 0, EMA_Medium_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
       double emaSlow = iMA(NULL, 0, EMA_Slow_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
       return (emaFast > emaMedium && emaMedium > emaSlow && Close[1] > emaSlow);
    }
    
    bool IsDowntrend() {
       double emaFast = iMA(NULL, 0, EMA_Fast_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
       double emaMedium = iMA(NULL, 0, EMA_Medium_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
       double emaSlow = iMA(NULL, 0, EMA_Slow_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
       return (emaFast < emaMedium && emaMedium < emaSlow && Close[1] < emaSlow);
    }

    Step 3: Candlestick Pattern Detection

    Detect bullish/bearish reversal patterns (e.g., engulfing, pin bars):

    bool IsBullishEngulfing() {
       if (Close[1] > Open[1] && Open[2] > Close[2] && Close[1] > Open[2] && Open[1] < Close[2]) 
          return true;
       return false;
    }
    
    bool IsBearishEngulfing() {
       if (Close[1] < Open[1] && Open[2] < Close[2] && Close[1] < Open[2] && Open[1] > Close[2]) 
          return true;
       return false;
    }

    Step 4: Entry Logic

    Combine trend + pullback + candlestick signal:

    void CheckEntries() {
       // Check if in trading session (optional)
       if (!IsTradingSession()) return;
    
       // Long entry (Buy)
       if (IsUptrend() && IsPullbackToEMA21() && (IsBullishEngulfing() || !UseCandlePatterns)) {
          double sl = Bid - StopLoss * Point;
          double tp = Bid + TakeProfit * Point;
          OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3, sl, tp, "Gold EA Buy", 0, 0, Green);
       }
    
       // Short entry (Sell)
       if (IsDowntrend() && IsPullbackToEMA21() && (IsBearishEngulfing() || !UseCandlePatterns)) {
          double sl = Ask + StopLoss * Point;
          double tp = Ask - TakeProfit * Point;
          OrderSend(Symbol(), OP_SELL, LotSize, Bid, 3, sl, tp, "Gold EA Sell", 0, 0, Red);
       }
    }

    Step 5: Exit Logic

    Close trades when TP/SL is hit or trend reverses:

    void CheckExits() {
       for (int i = OrdersTotal() - 1; i >= 0; i--) {
          if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
             // Close if trend reverses
             if ((OrderType() == OP_BUY && IsDowntrend()) || (OrderType() == OP_SELL && IsUptrend())) {
                OrderClose(OrderTicket(), OrderLots(), OrderType() == OP_BUY ? Bid : Ask, 3, Red);
             }
          }
       }
    }

    Step 6: Full EA Structure

    int OnInit() { return INIT_SUCCEEDED; }
    
    void OnTick() {
       CheckExits();  // Close trades if needed
       CheckEntries(); // Open new trades
    }

    How to Use the EA

    1. Copy the code into MetaEditor (File → New → Expert Advisor).
    2. Compile (F7) and attach to an MT4 chart (XAU/USD M15/H1).
    3. Adjust parameters (e.g., lot size, SL/TP, EMAs).
    4. Backtest in Strategy Tester (Ctrl+R) to verify the 70%+ win rate.

    Optimization Tips

    • Test different EMA periods (e.g., 5-9-21 vs. 9-21-50).
    • Adjust TP/SL ratios (e.g., 1:1.5 vs. 1:2).
    • Add trailing stops to maximize profits.

    Would you like me to add additional features (e.g., news filter, trailing stop)? Let me know! 🚀

  • Fixed WordPress Can’t Update

    The error message:

    Could not create directory.: /var/www/mikrotikscript.com/public_html/wp-content/upgrade
    Installation failed.
    

    means WordPress cannot write to the wp-content/upgrade directory due to file permission or ownership issues.


    ✅ Fix It in 3 Simple Steps:


    1. Ensure Correct Ownership

    Make sure the web server user (typically www-data for Nginx/Apache on Ubuntu/Debian) owns all WordPress files:

    sudo chown -R www-data:www-data /var/www/mikrotikscript.com/public_html
    

    Use apache:apache on CentOS/RHEL if you’re using Apache.


    2. Set Correct Permissions

    Ensure folders and files have proper permissions:

    # Directories: 755
    sudo find /var/www/mikrotikscript.com/public_html -type d -exec chmod 755 {} \;
    
    # Files: 644
    sudo find /var/www/mikrotikscript.com/public_html -type f -exec chmod 644 {} \;
    

    3. Ensure WordPress Uses Direct File Access

    Add this to wp-config.php, above the /* That's all, stop editing! */ line:

    define('FS_METHOD', 'direct');
    

    🧪 Optional: Create the upgrade Directory Manually

    Sometimes the upgrade folder doesn’t exist. Create it manually:

    mkdir -p /var/www/mikrotikscript.com/public_html/wp-content/upgrade
    chown www-data:www-data /var/www/mikrotikscript.com/public_html/wp-content/upgrade
    chmod 755 /var/www/mikrotikscript.com/public_html/wp-content/upgrade
    

    🔁 Then Try Again

    Now go back to WordPress Dashboard → Updates and try updating again.


  • การตั้งค่า mikrotik เบื้องต้น

    การตั้งค่า MikroTik เบื้องต้น

    เหมาะสำหรับผู้เริ่มต้นใช้งาน RouterOS เพื่อตั้งค่าเร้าเตอร์ MikroTik ให้ทำงานพื้นฐาน เช่น เชื่อมต่ออินเทอร์เน็ต, ตั้งค่า LAN, DHCP, Firewall และ NAT


    ขั้นตอนการตั้งค่าเบื้องต้น

    1. เข้าสู่ระบบ (Login)

    • เชื่อมต่อสาย Ethernet จากคอมพิวเตอร์ไปยัง Port ether1 (หรือใช้ WiFi หากรองรับ)
    • เปิดเบราว์เซอร์แล้วเข้า http://192.168.88.1 (หรือใช้ Winbox ดาวน์โหลดได้จาก MikroTik)
    • เข้าสู่ระบบด้วย:
      Username: admin
      Password: (เว้นว่างไว้หรือลอง admin)

    2. ตั้งค่าภาษาภายใน (LAN)

    2.1 กำหนด IP ให้ LAN

    /ip address add address=192.168.1.1/24 interface=bridge-lan
    • 192.168.1.1 = IP เร้าเตอร์
    • /24 = Subnet Mask (255.255.255.0)
    • bridge-lan = Interface ของ LAN (สร้าง Bridge ก่อนถ้าจำเป็น)

    2.2 สร้าง Bridge (ถ้ามีหลายพอร์ต LAN)

    /interface bridge add name=bridge-lan
    /interface bridge port add bridge=bridge-lan interface=ether2
    /interface bridge port add bridge=bridge-lan interface=ether3

    3. ตั้งค่า DHCP Server

    3.1 สร้าง IP Pool (ช่วง IP ที่จะแจก)

    /ip pool add name=dhcp-pool ranges=192.168.1.100-192.168.1.200

    3.2 ตั้งค่า DHCP Server

    /ip dhcp-server add interface=bridge-lan address-pool=dhcp-pool disabled=no
    /ip dhcp-server network add address=192.168.1.0/24 gateway=192.168.1.1 dns-server=8.8.8.8,1.1.1.1
    • gateway=192.168.1.1 = กำหนดให้ใช้เร้าเตอร์เป็น Gateway
    • dns-server=8.8.8.8,1.1.1.1 = DNS ของ Google และ Cloudflare

    4. ตั้งค่าอินเทอร์เน็ต (WAN)

    4.1 สำหรับ PPPoE (เช่น TOT, AIS Fiber)

    /interface pppoe-client add name=pppoe-out interface=ether1 user=username password=password
    • ether1 = พอร์ต WAN (ต่อสายจาก ONT/โมเด็ม)
    • user และ password = ข้อมูลที่ ISP ให้มา

    4.2 สำหรับ Dynamic IP (เช่น True, 3BB)

    /ip dhcp-client add interface=ether1

    5. ตั้งค่า NAT (ให้เครือข่าย LAN ออกอินเทอร์เน็ตได้)

    /ip firewall nat add chain=srcnat out-interface=pppoe-out action=masquerade
    • pppoe-out = ชื่ออินเทอร์เฟส WAN (เปลี่ยนเป็น ether1 ถ้าใช้ Dynamic IP)

    6. ตั้งค่า Firewall พื้นฐาน

    6.1 ป้องกันการเข้าถึงจากภายนอก

    /ip firewall filter add chain=input action=drop connection-state=invalid
    /ip firewall filter add chain=input action=accept connection-state=established,related
    /ip firewall filter add chain=input action=drop in-interface=pppoe-out protocol=tcp dst-port=23,8291
    • ปิด Telnet (port 23) และ Winbox (port 8291) จากอินเทอร์เน็ต

    6.2 อนุญาต Traffic จาก LAN ไปอินเทอร์เน็ต

    /ip firewall filter add chain=forward action=accept src-address=192.168.1.0/24

    7. บันทึกการตั้งค่า

    /system backup save name=initial-config

    เพื่อป้องกันการสูญเสียการตั้งค่าเมื่อรีเซ็ต


    สรุปการตั้งค่าเบื้องต้น

    การตั้งค่าคำสั่ง/ค่าที่ใช้
    IP LAN192.168.1.1/24
    DHCP Pool192.168.1.100-192.168.1.200
    PPPoE/interface pppoe-client add...
    NATchain=srcnat action=masquerade
    Firewalldrop invalid, allow LAN traffic

    ⚠️ หมายเหตุ:

    • เปลี่ยน ether1, pppoe-out, และช่วง IP ตามการใช้งานจริง
    • ใช้ Winbox หรือ WebFig สำหรับการตั้งค่าที่ง่ายกว่า

    หากต้องการตั้งค่าเพิ่มเติม เช่น Load Balancing, VPN, QoS สามารถสอบถามได้! 🚀ที่ 099-3988-999

  • WI-FI 7 ดีอย่างไร มีอะไรเหนือกว่า WI-FI 6

    สรุปเปรียบเทียบ WiFi 7 (802.11be) vs. WiFi 6 (802.11ax)

    จุดเด่นของ WiFi 7 ที่เหนือกว่า WiFi 6

    คุณสมบัติWiFi 6 (802.11ax)WiFi 7 (802.11be)ผลลัพธ์ที่ได้
    ความเร็วสูงสุดสูงสุด ~9.6 Gbpsสูงสุด ~46 Gbps (理論値)เร็วขึ้น ~4.8 เท่า
    ช่องสัญญาณ (Channel Width)สูงสุด 160 MHz320 MHz (ใช้คลื่น 6 GHz เต็มพิกัด)เพิ่มแบนด์วิธ 2 เท่า
    Modulation (QAM)1024-QAM4096-QAMส่งข้อมูลได้มากขึ้นต่อสัญญาณ
    Multi-Link Operation (MLO)ไม่มีรวมหลายช่องสัญญาณ (2.4/5/6 GHz) พร้อมกันลด Latency, รับส่งข้อมูลเสถียร
    Multi-RU (Resource Units)กำหนด RU แบบตายตัวแบ่งสัญญาณย่อย (RU) ยืดหยุ่นกว่าประสิทธิภาพในพื้นที่คลื่นแออัดดีขึ้น
    Latency~10 msต่ำกว่า 5 ms (เหมาะกับเกม/VR)การตอบสนองเร็วขึ้น
    จำนวน Spatial Streamsสูงสุด 8 streamsสูงสุด 16 streams (ใน enterprise)รองรับอุปกรณ์พร้อมกันมากขึ้น

    เงื่อนไขการใช้งานที่ WiFi 7 ดีกว่า WiFi 6

    1. พื้นที่ที่มีอุปกรณ์หนาแน่น
    • WiFi 7 จัดการความแออัดได้ดีกว่า (ด้วย MLO และ Multi-RU) เหมาะสำหรับออฟฟิศ, ห้างสรรพสินค้า
    1. แอปพลิเคชันที่ต้องการความเร็วสูง
    • 4K/8K Streaming, VR, Cloud Gaming (WiFi 7 ลดกระตุกได้ดีกว่า)
    1. ลด Ping สำหรับเกมเมอร์
    • MLO ช่วยลด latency ได้ถึง 50% เมื่อเทียบกับ WiFi 6
    1. ใช้งานคลื่น 6 GHz เต็มประสิทธิภาพ
    • WiFi 7 ใช้ 320 MHz channel ในคลื่น 6 GHz ได้ (WiFi 6 จำกัดที่ 160 MHz)

    ข้อจำกัดของ WiFi 7

    • ต้องใช้อุปกรณ์รองรับ (มือถือ/แล็ปท็อป WiFi 7)
    • ราคาแพงกว่า (Router WiFi 7 ยังมีราคาสูง)
    • คลื่น 6 GHz อาจถูกจำกัดในบางประเทศ

    สรุป: เลือก WiFi 7 เมื่อไหร่?

    • ถ้าต้องการ ความเร็วสุดขีด, latency ต่ำ (เกม/VR)
    • มี อุปกรณ์รองรับ WiFi 7 และงบประมาณเพียงพอ
    • ใช้งานในพื้นที่ที่ คลื่น WiFi แออัดมาก

    หากไม่ต้องการความเร็วสูงมาก WiFi 6 ก็ยังเพียงพอ สำหรับการใช้งานทั่วไป (เช่น บ้านทั่วไป, ออฟฟิศเล็ก)

    ⚠️ หมายเหตุ: WiFi 7 ยังใหม่มาก (เริ่มใช้งานปี 2024) ดังนั้นควรตรวจสอบความเข้ากันได้ของอุปกรณ์ก่อนอัปเกรด

  • mikrotik 2 wan Pppoe Load balance with Fail Over

    Here’s a complete MikroTik RouterOS script for your requirements:

    • 2 WAN PPPoE connections (load-balanced with NTH + failover)
    • LAN IP 172.23.34.0/24
    • Bandwidth limit (50Mbps per LAN client)
    • Basic firewall rules (security + NAT)

    Script

    /interface pppoe-client
    add name=pppoe-wan1 interface=ether1 user=user1 password=pass1 add-default-route=no
    add name=pppoe-wan2 interface=ether2 user=user2 password=pass2 add-default-route=no
    
    /ip pool
    add name=lan-pool ranges=172.23.34.100-172.23.34.200
    
    /ip dhcp-server
    add address-pool=lan-pool interface=bridge-lan disabled=no name=dhcp-lan
    
    /interface bridge
    add name=bridge-lan
    /interface bridge port
    add bridge=bridge-lan interface=ether3
    add bridge=bridge-lan interface=ether4
    # Add more LAN ports if needed
    
    /ip address
    add address=172.23.34.1/24 interface=bridge-lan network=172.23.34.0
    
    /ip dhcp-server network
    add address=172.23.34.0/24 gateway=172.23.34.1 dns-server=8.8.8.8,1.1.1.1
    
    /ip firewall mangle
    add chain=prerouting connection-state=new nth=2,1 action=mark-connection new-connection-mark=wan1_conn passthrough=yes
    add chain=prerouting connection-mark=wan1_conn action=mark-routing new-routing-mark=to_wan1 passthrough=no
    add chain=prerouting connection-state=new nth=2,2 action=mark-connection new-connection-mark=wan2_conn passthrough=yes
    add chain=prerouting connection-mark=wan2_conn action=mark-routing new-routing-mark=to_wan2 passthrough=no
    
    /ip route
    add dst-address=0.0.0.0/0 gateway=pppoe-wan1 routing-mark=to_wan1 check-gateway=ping
    add dst-address=0.0.0.0/0 gateway=pppoe-wan2 routing-mark=to_wan2 check-gateway=ping
    add dst-address=0.0.0.0/0 gateway=pppoe-wan1 distance=3
    add dst-address=0.0.0.0/0 gateway=pppoe-wan2 distance=4
    
    /ip firewall nat
    add chain=srcnat out-interface=pppoe-wan1 action=masquerade
    add chain=srcnat out-interface=pppoe-wan2 action=masquerade
    
    # Bandwidth limit (50Mbps per LAN client)
    /queue simple
    add name=limit-lan target=172.23.34.0/24 max-limit=50M/50M
    
    # Basic firewall rules
    /ip firewall filter
    add chain=input action=drop connection-state=invalid
    add chain=input action=accept connection-state=established,related
    add chain=input action=drop in-interface=pppoe-wan1 protocol=tcp dst-port=23,80,443,8291
    add chain=input action=drop in-interface=pppoe-wan2 protocol=tcp dst-port=23,80,443,8291
    add chain=forward action=fasttrack-connection connection-state=established,related
    add chain=forward action=accept connection-state=established,related
    add chain=forward action=drop connection-state=invalid

    Key Features:

    1. Dual WAN PPPoE Load Balancing
    • Uses NTH (every 2nd connection alternates between WAN1/WAN2).
    • Failover: If one PPPoE fails, traffic auto-switches.
    1. LAN Setup
    • DHCP server for 172.23.34.0/24.
    • Clients get IPs from 172.23.34.100-172.23.34.200.
    1. Bandwidth Limiting
    • Each LAN client restricted to 50Mbps up/down.
    1. Basic Firewall
    • Blocks invalid packets, protects RouterOS ports (Winbox/WebFig).
    • NAT for outbound traffic.

    How to Apply:

    1. Copy the script to Winbox Terminal (or SSH).
    2. Adjust:
    • pppoe-wan1/wan2 credentials.
    • LAN interfaces (ether3, ether4, etc.).
    1. Test failover by unplugging one PPPoE.

  • Hello world!

    Welcome to WordPress. This is your first post. Edit or delete it, then start writing!