Custom Trading Time and related features

LakshmiFX Expert Advisor User Manual

Welcome to LakshmiFX, a versatile Expert Advisor (EA) for MetaTrader 4 (MT4) and MetaTrader 5 (MT5). Designed to work with any broker, LakshmiFX automates trading across Forex, cryptocurrencies, gold, and other CFDs, giving you full control over when and how trades are executed. This manual explains how to set up and use LakshmiFX, with detailed guidance on its settings and behavior.


Overview

LakshmiFX is built to adapt to your trading preferences:

  • Monitors market status and notifies you when it opens or closes.
  • Lets you choose days to avoid trading (e.g., Fridays or Mondays).
  • Enforces a custom trading time window, with options for handling open trades outside that window.
  • Works seamlessly for day traders, swing traders, and anyone in between.

Whether you’re trading EURUSD over weekdays or holding BTCUSD positions over weekends, LakshmiFX ensures your strategy is respected.


Key Features

1. Market Status Monitoring

  • Checks if the market is open or closed when you start the EA.
  • Notifies you once at startup if the market is closed, then checks periodically (default: every 5 minutes).
  • Alerts you when the market opens, then proceeds with trading silently.

2. No-Trade Days

  • Define specific days (e.g., Friday, Monday) when no new trades should be opened.
  • Existing trades remain active and managed, ideal for swing traders holding positions over weekends.

3. Custom Trading Hours

  • Set a start and stop time for trading each day.
  • Choose what happens to open trades after the stop time:
    • Close them immediately.
    • Keep them open until they close naturally, with no new trades until the next day.

4. Flexible Trade Management

  • Manages open trades during market closures, no-trade days, or outside custom hours.
  • Ensures your strategy runs only when conditions (market status, day, time, spread) are met.

Market Check Settings

ParameterDescriptionDefaultExample
inpCheckIntervalMinutesHow often (in minutes) the EA checks if the market is open or closed when it’s initially closed.510
inpTickTimeoutSecondsTime (in seconds) since the last tick to consider the market closed.300600
  • How It Works:
    • At startup, LakshmiFX checks if the market is open (trading enabled and recent ticks received).
    • If closed, you’ll see a message like: “LakshmiFX > Magic: 1974 > EURUSD market is closed at 2025.03.18 00:00.”
    • It then checks every inpCheckIntervalMinutes (e.g., 5 minutes) and notifies you once when the market opens: “LakshmiFX > Magic: 1974 > EURUSD market is open at 2025.03.18 09:00.”
    • If open at startup, no notification is shown, and trading begins silently.
  • Example: Set inpCheckIntervalMinutes = 10 to check every 10 minutes if you’re trading a less active symbol like XAUUSD.

Trading Day Restrictions

ParameterDescriptionDefaultExample
inpNoTradeDaysDays of the week when no new trades are allowed (0=Sunday, 1=Monday, …, 5=Friday, 6=Saturday). Use commas for multiple days.“5”“1,5”
  • How It Works:
    • Enter day numbers separated by commas (e.g., “1,5” for Monday and Friday).
    • On these days, LakshmiFX won’t open new trades but will manage existing ones (e.g., adjust stops or take profits).
  • Example:
    • inpNoTradeDays = “5”: No new trades on Friday. If you have an open EURUSD trade from Thursday, it stays open and managed over the weekend.
    • inpNoTradeDays = “1,5”: No new trades on Monday or Friday. Useful if you want to avoid volatile Monday openings and Friday closings.

Custom Trading Time Settings

ParameterDescriptionDefaultExample
inpUseCustomTradingTimeEnable/disable custom trading hours. If false, trades anytime the market is open and not a no-trade day.falsetrue
inpStartHourHour (0-23) to start trading each day.19
inpStopHourHour (0-23) to stop trading each day.1117
inpActionAfterSessionWhat to do with open trades after inpStopHour: <br> – CLOSE_TRADES: Close all trades immediately. <br> – WAIT_FOR_SEQUENCE: Keep trades open, no new trades until next inpStartHour.WAIT_FOR_SEQUENCECLOSE_TRADES
  • How It Works:
    • If inpUseCustomTradingTime = true, trading only occurs between inpStartHour and inpStopHour (in server time).
    • Within Hours: New trades can open, and existing trades are managed.
    • Outside Hours:
      • No open trades: No new trades until inpStartHour the next day.
      • Open trades:
        • CLOSE_TRADES: Closes all trades at inpStopHour (e.g., “Outside trading hours. Closing 2 open trade(s)…”).
        • WAIT_FOR_SEQUENCE: Keeps trades open, manages them, but blocks new trades until inpStartHour (e.g., “Outside trading hours. Keeping 2 trade(s) open, no new trades allowed.”).
  • Example:
    • inpStartHour = 9, inpStopHour = 17, inpActionAfterSession = CLOSE_TRADES:
      • Trades from 9:00 to 17:00 server time. At 17:00, all open trades close.
    • inpStartHour = 22, inpStopHour = 6, inpActionAfterSession = WAIT_FOR_SEQUENCE:
      • Trades from 22:00 to 6:00 (overnight). After 6:00, open trades stay active but no new trades until 22:00 next day.

How LakshmiFX Works

Startup

  1. Market Check: On initialization, LakshmiFX checks if the market is open or closed:
    • Closed: Notifies you once, then checks every inpCheckIntervalMinutes until it opens.
    • Open: Proceeds silently without notification.
  2. Settings Validation: Ensures your inputs (e.g., inpNoTradeDays, hours) are valid.

Trading Process

  1. New Bar Check: Executes trading logic only on new bars (e.g., every hour on H1 charts).
  2. Trading Conditions:
    • Market Open: Must be active (trading enabled and recent ticks).
    • Allowed Day: Not listed in inpNoTradeDays.
    • Within Time: Within inpStartHour to inpStopHour if custom time is enabled.
    • Spread OK: Spread below inpMaxSpread.
  3. Actions:
    • All conditions met: Runs TradeLogic() to open new trades and manage existing ones.
    • Any condition fails: Manages open trades only, no new trades.

Open Trade Management

  • If the market closes, it’s a no-trade day, or you’re outside custom hours:
    • Open trades are monitored and managed (e.g., adjusting stops or profits, depending on your TradeLogic()).
    • New trades are blocked until conditions are met again.

Usage Examples

Day Trader: Avoid Fridays, Trade 9-5

  • Settings:
    • inpNoTradeDays = “5”
    • inpUseCustomTradingTime = true
    • inpStartHour = 9
    • inpStopHour = 17
    • inpActionAfterSession = CLOSE_TRADES
  • Behavior:
    • Trades Monday-Thursday, 9:00-17:00 server time.
    • At 17:00, closes all trades.
    • No new trades on Friday; manages open trades from Thursday if any.

Swing Trader: Trade All Week, Overnight

  • Settings:
    • inpNoTradeDays = “” (empty, no restrictions)
    • inpUseCustomTradingTime = true
    • inpStartHour = 22
    • inpStopHour = 6
    • inpActionAfterSession = WAIT_FOR_SEQUENCE
  • Behavior:
    • Trades 22:00-6:00 daily.
    • After 6:00, keeps open trades (e.g., over weekends), no new trades until 22:00.
    • Ideal for holding positions over multiple days.

Crypto Trader: Avoid Mondays

  • Settings:
    • inpNoTradeDays = “1”
    • inpUseCustomTradingTime = false
  • Behavior:
    • Trades 24/7 except Mondays.
    • If the market closes (e.g., broker downtime), notifies you and manages open trades until it reopens.

Troubleshooting

  • No Trades Opening:
    • Check inpMaxSpread—set higher if your broker’s spread is wide.
    • Verify server time matches your inpStartHour/inpStopHour.
    • Ensure inpNoTradeDays doesn’t include today.
  • No Notifications:
    • Enable “Allow WebRequest” for MT5 push notifications in Tools > Options > Expert Advisors.
  • EA Stops:
    • If “less than 60 bars” alert appears, switch to a longer history chart (e.g., D1 instead of M1).

Technical Details

  • Market Status: Uses SYMBOL_TRADE_MODE and tick activity (within inpTickTimeoutSeconds) to determine if the market is open.
  • Time: Based on broker server time, not local time.
  • MT4/MT5 Compatibility: Works on both platforms with consistent behavior.

Support

For questions or assistance, visit https://lakshmifx.com/support or register at https://lakshmifx.com/register.

Trade with confidence using LakshmiFX—your customizable trading companion!


Notes for Users

  • Server Time: Check your broker’s server time (visible in MT4/MT5 Market Watch) to set inpStartHour and inpStopHour correctly.
  • Swing Trading: Use WAIT_FOR_SEQUENCE and avoid restrictive inpNoTradeDays to hold trades over weekends.
  • Testing: Run in the MT4/MT5 Strategy Tester with different settings to see how LakshmiFX behaves with your strategy.

Share the Post:

Related Posts

Join Our Newsletter

Scroll to Top