fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. bacharchoura1
    B
    • Profile
    • Following 1
    • Followers 0
    • Topics 46
    • Posts 108
    • Best 0
    • Controversial 0
    • Groups 0

    bacharchoura1

    @bacharchoura1

    trader

    0
    Reputation
    26
    Profile views
    108
    Posts
    0
    Followers
    1
    Following
    Joined Last Online
    Location dubai-uae Age 62

    bacharchoura1 Unfollow Follow

    Latest posts made by bacharchoura1

    • RE: how to integrate an external EA in fx dreema made EA?

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

      posted in Questions & Answers
      B
      bacharchoura1
    • how to integrate an external EA in fx dreema made EA?

      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);
      }
      }
      //+------------------------------------------------------------------+

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      image.png

      as you can see hear i did exactly as per your instruction but still i am getting the following error massage :

      image.png

      can you pls rectify , tks
      rgds

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      GOOD DAY TO YOU:
      AS PER YOUR INSTRUCTION ADDING THE CODE YOU SENT ABOVE RESULT IN FUNCTION THE FOLLOWING CODE :
      void CloseAllPositions() {
      for (int cnt = PositionsTotal() - 1; cnt >= 0 && !IsStopped(); cnt--) {
      if (PositionGetTicket(cnt)) {
      sTrade.PositionClose(PositionGetInteger(POSITION_TICKET), 100);
      uint code = sTrade.ResultRetcode();
      Print("Close result code: ", IntegerToString(code));
      }
      }
      }

      void PrintPerformance(ulong startTime) {
      for (int i = 0; i < 100; i++) {
      Print("Elapsed time: ", IntegerToString(GetMicrosecondCount() - startTime), " microseconds. Open positions: ", IntegerToString(PositionsTotal()));
      if (PositionsTotal() <= 0) { break; }
      Sleep(100);
      }
      }
      void CloseAllPositions(ulong MagicStart)
      {
      for (int cnt = PositionsTotal() - 1; cnt >= 0 && !IsStopped(); cnt--)
      {
      if (PositionSelectByIndex(cnt))
      {
      ulong ticket = PositionGetInteger(POSITION_TICKET);
      long magic = PositionGetInteger(POSITION_MAGIC);

       // Only close positions matching the EA's magic number
       if (magic == (long)MagicStart)
       {
          sTrade.PositionClose(ticket, 100);
          uint code = sTrade.ResultRetcode();
          Print("Close result code: ", IntegerToString(code), " | Ticket: ", ticket);
       }
      

      }
      }
      }
      BUT NOW I AM GETTING THIS ERROR UPON COMPILING :

      CAN YOU PLS TELL ME WHAT IS WRONG ?? HOW TO FIX ? TKS
      image.png

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      DEAR SIR
      https://fxdreema.com/shared/xqWIR5Zrd
      FOLLOWING YOUR INSTRUCTIONS TO CREATE A CUSTOM CLOSE ALL GROUP , IT WORKS SO GOOD AND CLOSE ALL TRADES ENOUGH FAST , THE PROBLEM IS THAT IT CLOSES ALL TRADES EVEN IF MANUALY OPENED AND INDIPENDENTLY EVEN OF THE MAGIC NUMBER..
      I ADDED THE PINCK (FOR EACH POSITIONS) BLOCK IT CONTINUE TO CLOSE ALLL ALL OPENED POSITIONS INDIPENDENTLY OF THE MAGIC NUMBER OR THE POSITION TYPE...!!!
      CAN YOU PLS HELP FOR MAKING IT CLOSE ONLY POSITIONS WITH A SPECIFIC MAGIC NUMBER OR POSITION DIRECTION TYPE (BUY OR SELL)..!!
      THANKYOU FOR YOUR KIND SUPPORT
      RGDS

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      YOU ARE GRATE ... DONE .. THANK YOU VERY MUCH

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      thank you very much for your expirienced replay.
      a final question please : in this strategy hundreds of buy/sell trades will be opened and i an suffering looses due to delay in closeing them using "close positions" block since it close them one by one which cobers few mintes even on VPS..
      i hope you can faind a solution for fast closing ...
      thank you very much for every thing
      rgds

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      dear sir
      I am not sure if you could perfectly consider what I want.
      Each time a new BUY position is opened, the EA must look at the total current buy profit of CURRENT OPENED BUY POSTIONS and store this profit in a variable.
      The same for SELL positions.
      I wonder that you are asking me to use: “FOR EACH CLOSED POSITION” which has nothing to do with the current opened position...!!!
      Probably It is mistake ..alternatively I hope you can explain more or better just amend this shared EA..!!
      According to the best of my knowledge I did modify the EA to achieve this target , kindly have a look and tell me if it is correct like that …tks
      https://fxdreema.com/shared/uoEURx60d

      Thank you for your support
      rgds

      posted in Questions & Answers
      B
      bacharchoura1
    • what is the difference between close and close psitions blocks/

      good day
      https://fxdreema.com/shared/pJtAMF4se
      hear we have 2 blockes close and close positions..
      please , can anyone tell me :
      1-what is the difference ?
      2-is their any whay to quickly close all trades when i have few hundreds of opened trades ..because in this case it covers 2-3 minutes to close them using "close position: block so we suffer slippage..!
      3-is it necessay to put "for each position" block before the "close' block to make it run proparly ?
      thankyou for all your support
      rgds

      posted in Questions & Answers
      B
      bacharchoura1
    • RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?

      Dear Mr Jstap
      Simply: how to store the :
      TOTAL PROFIT OF THE “TOTAL CURRENT BUY POSITIONS” AT THE MOMENT OF ADDING A NEW POSITION BUY in a variable.
      AND
      TOTAL PROFIT OF THE “TOTAL CURRENT SELL POSITIONS” AT THE MOMENT OF ADDING A NEW POSITION SELL in a different variable.
      In this project : https://fxdreema.com/shared/opyzomi2e ,I am comparing the “current profit” with the “last opened position” profit and make the buy/sell decision, but my problem is that I am not able to store the ‘total profit at last position” buy or sell in variables correctly.
      It seems -not sure- that if i put these blocked under trade instead of under tick and eliminate the pink blocks it works but in this case it is impossible to optimize the EA independently of the computing power and resources.
      Hope you can help
      Kind regards
      Bachar

      posted in Questions & Answers
      B
      bacharchoura1