fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    how to integrate an external EA in fx dreema made EA?

    Questions & Answers
    3
    5
    38
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bacharchoura1 last edited by

      good moring ,
      i want to create an EA that detects the nearest support and resistance level to the currently opened position using daily pivot channel indicator so thati can set the TP SL.
      i could not do it in fx dreema .. can you help with this ?? tks.
      alternativly i could make it using AI buy still i need to integrate the AI code with my EA made in fx dreema , eventually by adding a custom block or condition... can you please tell me how to do that ? : following is the AI code : #property copyright "Meta AI"
      #property version "1.2"
      #property strict

      #include <Trade\Trade.mqh>

      CTrade trade;

      //--- Input parameters
      input double TP_Percent = 20; // Take Profit percentage of the distance between support and resistance (%)

      //+------------------------------------------------------------------+
      void OnTick()
      {
      string currentSymbol = Symbol(); // Current chart symbol

      //--- Calculate daily pivot levels
      double high1 = iHigh(NULL, PERIOD_D1, 1);
      double low1 = iLow(NULL, PERIOD_D1, 1);
      double close1 = iClose(NULL, PERIOD_D1, 1);

      if(high1 == 0 || low1 == 0 || close1 == 0) return;

      double P = (high1 + low1 + close1) / 3.0;
      double R1 = (2 * P) - low1;
      double S1 = (2 * P) - high1;
      double R2 = P + (high1 - low1);
      double S2 = P - (high1 - low1);
      double M1 = (P + S1) / 2.0;
      double M2 = (S1 + S2) / 2.0;
      double M3 = (P + R1) / 2.0;
      double M4 = (R1 + R2) / 2.0;

      double levels[] = {R2, R1, M4, M3, P, M1, S1, M2, S2};
      double currentPrice = SymbolInfoDouble(currentSymbol, SYMBOL_BID);
      double support = EMPTY_VALUE;
      double resistance = EMPTY_VALUE;

      //--- Find nearest support and resistance levels
      for(int i = 0; i < ArraySize(levels); i++)
      {
      if(levels[i] > currentPrice && (resistance == EMPTY_VALUE || levels[i] < resistance))
      resistance = levels[i];
      if(levels[i] < currentPrice && (support == EMPTY_VALUE || levels[i] > support))
      support = levels[i];
      }

      if(support == EMPTY_VALUE || resistance == EMPTY_VALUE) return;

      //--- Draw support and resistance lines
      ObjectDelete(0, "Support");
      ObjectDelete(0, "Resistance");

      ObjectCreate(0, "Support", OBJ_HLINE, 0, TimeCurrent(), support);
      ObjectSetInteger(0, "Support", OBJPROP_COLOR, clrGreen);
      ObjectSetInteger(0, "Support", OBJPROP_WIDTH, 2);
      ObjectSetString(0, "Support", OBJPROP_TEXT, "Support: " + DoubleToString(support, _Digits));

      ObjectCreate(0, "Resistance", OBJ_HLINE, 0, TimeCurrent(), resistance);
      ObjectSetInteger(0, "Resistance", OBJPROP_COLOR, clrRed);
      ObjectSetInteger(0, "Resistance", OBJPROP_WIDTH, 2);
      ObjectSetString(0, "Resistance", OBJPROP_TEXT, "Resistance: " + DoubleToString(resistance, _Digits));

      //--- Modify Take Profit for open positions on the current symbol
      for(int i = PositionsTotal() - 1; i >= 0; i--)
      {
      ulong ticket = PositionGetTicket(i);
      if(PositionSelectByTicket(ticket))
      {
      // Check if the position is on the same symbol
      if(PositionGetString(POSITION_SYMBOL) == currentSymbol)
      {
      double gap = resistance - support;
      double tpLevel;
      double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);
      double currentTP = PositionGetDouble(POSITION_TP);

              if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
              {
                 tpLevel = NormalizeDouble(resistance - (gap * TP_Percent / 100.0), _Digits);
                 if(tpLevel > openPrice && (currentTP == 0 || MathAbs(currentTP - tpLevel) > _Point))
                    TradeModifyTake(ticket, tpLevel);
              }
              else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
              {
                 tpLevel = NormalizeDouble(support + (gap * TP_Percent / 100.0), _Digits);
                 if(tpLevel < openPrice && (currentTP == 0 || MathAbs(currentTP - tpLevel) > _Point))
                    TradeModifyTake(ticket, tpLevel);
              }
           }
        }
      

      }
      }

      //+------------------------------------------------------------------+
      //| Modify Take Profit for a position |
      //+------------------------------------------------------------------+
      void TradeModifyTake(ulong ticket, double tp)
      {
      MqlTradeRequest request;
      MqlTradeResult result;
      ZeroMemory(request);
      ZeroMemory(result);

      request.action = TRADE_ACTION_SLTP;
      request.position = ticket;
      request.symbol = PositionGetString(POSITION_SYMBOL);
      request.tp = tp;
      request.sl = PositionGetDouble(POSITION_SL);

      bool success = OrderSend(request, result);
      if(!success)
      {
      Print("OrderSend failed. Error: ", GetLastError(), " Ticket: ", ticket);
      }
      else
      {
      Print("Take Profit updated successfully for ticket: ", ticket, " New TP: ", tp);
      }
      }
      //+------------------------------------------------------------------+

      in god we trust

      1 Reply Last reply Reply Quote 0
      • S
        sktsec last edited by sktsec

        Better start from scratch in fxDreema.

        If you want to make use of AI, better use it to develop an indicator first then be used in fxDreema.

        Or you can completely use AI to develop the EA, but it seems to me not as flexible as fxDreema

        1 Reply Last reply Reply Quote 0
        • jstap
          jstap last edited by

          @sktsec @bacharchoura1 I disagree with that FX has a lot of very useful blocks, AI can be smart but sometimes too smart. Mixing custom code blocks, indicators, FX blocks can all work together well. This picture shows the amount of AI generated, checked and perfected blocks I am currently using.

          msedge_seSfNhzY2n.png

          Learn fxDreema Without the Wait!

          My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

          The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

          Don’t miss out

          Click here➡️ https://mybook.to/fxDreema to get your copy today!

          Enjoy! 😊

          S 1 Reply Last reply Reply Quote 1
          • S
            sktsec @jstap last edited by

            @jstap
            Thanks for sharing. The pipeline integration is inspiring.

            1 Reply Last reply Reply Quote 0
            • B
              bacharchoura1 last edited by

              I FEEL TO BE A FREIND OF YOU..I LIKE TO BE IN ONE COMMUNITY...

              in god we trust

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              Online Users

              M
              F
              M
              L
              F
              F
              E
              K
              M
              T
              A

              35
              Online

              146.6k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors