fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Adam692
    3. Posts
    A
    • Profile
    • Following 0
    • Followers 1
    • Topics 3
    • Posts 10
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by Adam692

    • RE: How to Get Broker's Trading Hours and Allow Trading for the First 30 Minutes of the Last Hour?

      @jstap I tried multiple times to fix the code with AI, but there were always errors. This version of the code had the least errors, so I’m sharing it now:
      // Custom Code for FxDreema to handle last hour trading logic

      // Ensure the platform is MT5
      #ifdef MQL5

      // Get the current server time
      datetime currentTime = TimeCurrent();

      // Get the trading session end time for the current symbol
      datetime sessionEndTime = (datetime)SymbolInfoInteger(_Symbol, SYMBOL_SESSION_END);

      // Calculate the difference in seconds between the current time and session end time
      int secondsToEnd = (int)(sessionEndTime - currentTime);

      // Check if we are in the last hour of trading
      if (secondsToEnd <= 3600 && secondsToEnd > 0) // 3600 seconds = 1 hour
      {
      if (!isLastHourActive) // If not already active
      {
      isLastHourActive = true;
      lastHourStartTime = currentTime; // Record the start time
      }
      }

      // Deactivate after 30 minutes
      if (isLastHourActive && (currentTime - lastHourStartTime) > 1800) // 1800 seconds = 30 minutes
      {
      isLastHourActive = false;
      }

      #else
      Print("This code requires MT5 platform.");
      #endif

      These are the error messages I received:
      'SYMBOL_SESSION_END' - undeclared identifier
      'SymbolInfoInteger' - no one of the overloads can be applied to the function call

      I asked the AI to analyze the code, and this is the explanation it provided:

      The provided code snippet is designed to handle logic related to the last hour of trading for a specific symbol. Here's an analysis of its components:


      1. Platform Check

      #ifdef MQL5
      • Purpose: Ensures that the code is only executed on the MetaTrader 5 (MT5) platform. If the platform is not MT5, the code will not run and will instead print a message.


      1. Current Server Time

      datetime currentTime = TimeCurrent();
      • Purpose: Retrieves the current server time. This is used as the reference point for all time-based calculations.


      1. Trading Session End Time

      datetime sessionEndTime = (datetime)SymbolInfoInteger(_Symbol, SYMBOL_SESSION_END);
      • Purpose: Fetches the end time of the trading session for the current symbol (_Symbol).
      • Key Function: SymbolInfoInteger retrieves symbol-specific properties, and SYMBOL_SESSION_END provides the session's end time.


      1. Time Difference Calculation

      int secondsToEnd = (int)(sessionEndTime - currentTime);
      • Purpose: Calculates the number of seconds remaining until the trading session ends.
      • Key Variable: secondsToEnd is used to determine if the current time is within the last hour of trading.


      1. Last Hour Activation

      if (secondsToEnd <= 3600 && secondsToEnd > 0) // 3600 seconds = 1 hour
      {
      if (!isLastHourActive) // If not already active
      {
      isLastHourActive = true;
      lastHourStartTime = currentTime; // Record the start time
      }
      }
      • Purpose: Checks if the current time is within the last hour of trading (secondsToEnd <= 3600).
      • Logic:
      o If the condition is met and the isLastHourActive flag is not already set, it activates the flag and records the start time of the last hour.


      1. Deactivation After 30 Minutes

      if (isLastHourActive && (currentTime - lastHourStartTime) > 1800) // 1800 seconds = 30 minutes
      {
      isLastHourActive = false;
      }
      • Purpose: Deactivates the isLastHourActive flag if 30 minutes have passed since the last hour started.
      • Logic:
      o Ensures that the logic only remains active for the first 30 minutes of the last hour.


      1. Fallback for Non-MT5 Platforms

      #else
      Print("This code requires MT5 platform.");
      #endif
      • Purpose: Prints a message if the code is executed on a platform other than MT5.
      • Fallback Behavior: Prevents execution on unsupported platforms.


      Key Variables

      1. isLastHourActive:
        o A boolean flag indicating whether the last hour logic is active.
      2. lastHourStartTime:
        o Stores the time when the last hour logic was activated.

      Summary
      • The code is designed to monitor the last hour of trading for a symbol and activate specific logic during this period.
      • It ensures compatibility with MT5 and gracefully handles unsupported platforms.
      • The logic is time-sensitive, activating for the first 30 minutes of the last hour and deactivating afterward.

      https://fxdreema.com/shared/ivT0aNgqc

      posted in Questions & Answers
      A
      Adam692
    • RE: How to Get Broker's Trading Hours and Allow Trading for the First 30 Minutes of the Last Hour?

      @jstap If I connect it to anything, I get an error message when I try to compile it.
      02.png

      posted in Questions & Answers
      A
      Adam692
    • How to Get Broker's Trading Hours and Allow Trading for the First 30 Minutes of the Last Hour?

      I want to use a custom code that retrieves the broker's trading hours and allows trading for the first 30 minutes of the last trading hour, then disables it.

      I'm not an experienced coder, and I tried generating the code with Copilot, but it doesn’t place trades.

      Does anyone have a working solution for this?

      Here’s my draft: https://fxdreema.com/shared/2ohjfaKyb

      posted in Questions & Answers customcode expertadvisor brokertime mql5
      A
      Adam692
    • RE: Issues with Trailing Stop Errors in MT5

      @ambrogio Alright, I will increase the breakeven value, but I have already tried turning off the breakeven and increasing the trailing stop distance. Errors still occurred, although perhaps less frequently. Thank you for the advice.

      posted in Questions & Answers
      A
      Adam692
    • RE: Issues with Trailing Stop Errors in MT5

      @ambrogio I am trying to create a scalper expert that places pending orders at the peaks and troughs of the zig zag indicator, followed by a tight trailing stop to follow the price. I intend to use this for indices and gold. Here is the outline: https://fxdreema.com/shared/4Ntt1K6Cc

      It mostly works, but I wonder if there is a simpler way to achieve this, and I would appreciate any suggestions.

      I have a stop modification feature because pending orders do not allow stops to be placed closer than a certain point, so I modify them afterward.

      The issue seems to be that the trailing stop is too close, but this is strange to me because even when I adjusted it to a greater distance, I still received errors. Additionally, many scalper experts work with tight stops and a few pips of take profit without reporting errors. Those experts were obviously not made with FXDreema, but how do they manage to work error-free?

      posted in Questions & Answers
      A
      Adam692
    • Issues with Trailing Stop Errors in MT5

      Hi everyone,

      I've been encountering some error messages when using trailing stops in MT5. Here are the specific error messages I am receiving:
      failed modify #650 sell 0.31 XAUUSD sl: 2324.72, tp: 2312.32 -> sl: 2319.96, tp: 2312.32 [Invalid stops]
      2024.04.24 12:26:06
      failed modify #0 buy 0 sl: 0.00, tp: 0.00 -> sl: 2313.53, tp: 2305.32 [Invalid parameters]
      2024.04.24 18:00:38
      failed modify #0 buy 0 sl: 0.00, tp: 0.00 -> sl: 2333.47, tp: 2341.53 [Invalid parameters]

      If anyone knows how to resolve these issues, please share your insights. Any help would be greatly appreciated!

      Thanks in advance!

      posted in Questions & Answers mt5 errormessages trailingstop
      A
      Adam692
    • RE: Pending order, loop after loss. Help

      @l-andorrà Thank you, I will try.

      posted in Questions & Answers
      A
      Adam692
    • RE: Pending order, loop after loss. Help

      Yes, I have used variables before. Should the new size be calculated with a formula? Should the consecutive losses be checked with the "Check consecutive losses" block? How should it be assembled?

      posted in Questions & Answers
      A
      Adam692
    • RE: Pending order, loop after loss. Help

      @l-andorrà Yes, my intention is to have one trade per day, and for the next three trades, for three days or until activated, set the stop order with three times the lot size. After that, it should revert to the original.

      posted in Questions & Answers
      A
      Adam692
    • Pending order, loop after loss. Help

      Hello, I would like to ask for help with a simple breakout strategy using pending orders, using a trailing stop. The idea is to place pending orders in both directions during a specific time period every day. If not triggered, they should be canceled at the end of the day. What I want is that after a losing trade, under the same conditions, the EA should place three pending orders three times the size. I've tried using Martingale and a loop, but I couldn't achieve the desired result. I would be grateful if someone could help. If you have any suggestions for better solutions to the previous ones, I would appreciate it. This is how it looks now.

      posted in Questions & Answers help fxdreema pending order loop expert advisor
      A
      Adam692
    • 1 / 1