fxDreema

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

    Expert programmer gives solutions to any problem just ask me

    Questions & Answers
    16
    49
    7238
    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.
    • l'andorrà
      l'andorrà @Kevin0214 last edited by

      @Kevin0214 I already replied to your question in the other thread. Please don't duplicate threads.

      (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

      (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

      (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

      1 Reply Last reply Reply Quote 0
      • R
        rforeign last edited by

        Hello,
        how to create this rule in fxdreema blocks:
        A long position is closed when it has moved ATR3 down from its highest closing price since the position was opened.
        I mean highest closed price since the position was open. Every closed bar should be controlled if is highest from open price and if yes then trailling -ATR
        3 should be checked. Number of bars from open bar is not defined, continuous process.
        Thanks

        l'andorrà 1 Reply Last reply Reply Quote 0
        • l'andorrà
          l'andorrà @rforeign last edited by

          @rforeign Could you please open a new thread for your question instead of using this one?

          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

          1 Reply Last reply Reply Quote 0
          • F
            funmi last edited by funmi

            ........

            1 Reply Last reply Reply Quote 0
            • F
              funmi @Monaco last edited by

              @Monaco I created a Bot with fxdreema that sells and buys based on the condition I gave it. So, I want to create another bot to manage the trades based on the following conditions:

              The bot should check the last closed trade, if it was a loss, then enter the opposite direction immediately using same stoploss pips and take profit pips and
              double the lotsize.

              Can you help me please? Thanks.

              1 Reply Last reply Reply Quote 0
              • K
                karachiyan @Monaco last edited by

                @Monaco hi i have this error
                how can i find that the error belongs to which block?
                Compilation errors
                'CurrentSymbol' - function not defined
                'CurrentSymbol' - constant expected

                1 Reply Last reply Reply Quote 0
                • Monaco
                  Monaco Banned @biztet last edited by

                  @biztet Screenshot_82.png Sorry for the delay, I didn't quite understand when you wanted it to activate.

                  1 Reply Last reply Reply Quote 0
                  • Monaco
                    Monaco Banned @EA NEL last edited by

                    @EA-NEL Hola lo que entiendo es que primero debes controlar el uso de como tienes la condicion, un cruce de MA es sencillo pero a la misma ves "complejo"Screenshot_83.png Screenshot_84.png
                    Asi estrictamente estarias definiendo un cruce bajista Screenshot_85.png existe este (x>) pero nunca lo he usado. Es por esa razon que recibes notifiaciones siempre, por que quizas no esta bien condicionado

                    1 Reply Last reply Reply Quote 0
                    • Monaco
                      Monaco Banned @Kevin0214 last edited by Monaco

                      @Kevin0214

                      Variables and Preparation
                      Define the variables needed to identify the oldest trade or the one furthest from the current price:

                      // Variables for tracking the furthest or oldest losing trade
                      double max_distance = 0; // Max distance from current price, initialized to zero
                      double lot_to_close = 0.1; // Lot size to close partially
                      int selected_ticket = -1;  // Ticket ID of the selected trade for partial close
                      
                      // Loop through all open trades to find the oldest or furthest losing trade
                      for (int i = OrdersTotal() - 1; i >= 0; i--) {
                          if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
                              // Only consider trades on the current symbol and open positions
                              if (OrderSymbol() == Symbol() && (OrderType() == OP_BUY || OrderType() == OP_SELL)) {
                                  double current_price = (OrderType() == OP_BUY) ? Bid : Ask; // Determine current price based on trade type
                                  double order_price = OrderOpenPrice();
                                  double distance = MathAbs(current_price - order_price); // Calculate distance from current price
                      
                                  // Check if the trade is in loss
                                  if (OrderProfit() < 0) {
                                      // Select the oldest or furthest trade in loss
                                      if (distance > max_distance || selected_ticket == -1) {
                                          max_distance = distance;
                                          selected_ticket = OrderTicket();
                                      }
                                  }
                              }
                          }
                      }
                      
                      // If a trade was found, proceed to partially close it
                      if (selected_ticket != -1) {
                          // Select the trade by ticket ID
                          if (OrderSelect(selected_ticket, SELECT_BY_TICKET, MODE_TRADES)) {
                              double remaining_lots = OrderLots() - lot_to_close; // Calculate remaining lots after partial close
                      
                              // Check if the remaining lot size is above the minimum allowed
                              if (remaining_lots >= MarketInfo(Symbol(), MODE_MINLOT)) {
                                  bool close_result = OrderClose(selected_ticket, lot_to_close, OrderClosePrice(), Slippage, clrRed);
                                  if (close_result) {
                                      Print("Partial close successful for trade with ticket: ", selected_ticket);
                                  } else {
                                      Print("Error attempting partial close. Error code: ", GetLastError());
                                  }
                              } else {
                                  Print("Cannot partially close; remaining size would be below minimum lot size.");
                              }
                          }
                      } else {
                          Print("No eligible trade found for partial close.");
                      }
                      
                      

                      Function for Partial Close on Oldest/Furthest Losing Trade
                      To make this process reusable, here’s a function that you can call whenever you want to perform this action.

                      void PartialCloseOldestFurthestLoss(double lot_to_close, int slippage) {
                          double max_distance = 0; // Max distance from current price
                          int selected_ticket = -1;  // Ticket ID of the selected trade for partial close
                      
                          // Loop through all open trades to find the oldest or furthest losing trade
                          for (int i = OrdersTotal() - 1; i >= 0; i--) {
                              if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
                                  // Only consider trades on the current symbol and open positions
                                  if (OrderSymbol() == Symbol() && (OrderType() == OP_BUY || OrderType() == OP_SELL)) {
                                      double current_price = (OrderType() == OP_BUY) ? Bid : Ask; // Determine current price based on trade type
                                      double order_price = OrderOpenPrice();
                                      double distance = MathAbs(current_price - order_price); // Calculate distance from current price
                      
                                      // Check if the trade is in loss
                                      if (OrderProfit() < 0) {
                                          // Select the oldest or furthest trade in loss
                                          if (distance > max_distance || selected_ticket == -1) {
                                              max_distance = distance;
                                              selected_ticket = OrderTicket();
                                          }
                                      }
                                  }
                              }
                          }
                      
                          // If a trade was found, proceed to partially close it
                          if (selected_ticket != -1) {
                              // Select the trade by ticket ID
                              if (OrderSelect(selected_ticket, SELECT_BY_TICKET, MODE_TRADES)) {
                                  double remaining_lots = OrderLots() - lot_to_close; // Calculate remaining lots after partial close
                      
                                  // Check if the remaining lot size is above the minimum allowed
                                  if (remaining_lots >= MarketInfo(Symbol(), MODE_MINLOT)) {
                                      bool close_result = OrderClose(selected_ticket, lot_to_close, OrderClosePrice(), slippage, clrRed);
                                      if (close_result) {
                                          Print("Partial close successful for trade with ticket: ", selected_ticket);
                                      } else {
                                          Print("Error attempting partial close. Error code: ", GetLastError());
                                      }
                                  } else {
                                      Print("Cannot partially close; remaining size would be below minimum lot size.");
                                  }
                              }
                          } else {
                              Print("No eligible trade found for partial close.");
                          }
                      }
                      
                      

                      Explanation of the Function
                      Function Parameters:

                      lot_to_close: The lot size you want to close from the selected trade.
                      slippage: The allowable slippage for the close operation.
                      Selecting the Trade:

                      Loops through all open trades and finds the trade with the maximum distance from the current price that is also in loss.
                      Updates selected_ticket with the ticket ID of this trade.
                      Partial Close Execution:

                      If a trade is found, the function attempts a partial close by calling OrderClose.
                      Checks if the remaining lot size will be above the minimum allowed to ensure the trade remains valid.
                      Usage Example
                      To use this function, you can simply call it with the desired lot size to close and slippage:
                      PartialCloseOldestFurthestLoss(0.1, 3); // Partially closes 0.1 lots with 3 pips of allowable slippage

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

                      Online Users

                      A
                      G
                      Q
                      C
                      T
                      S
                      A
                      M
                      R
                      G

                      18
                      Online

                      146.7k
                      Users

                      22.4k
                      Topics

                      122.6k
                      Posts

                      Powered by NodeBB Forums | Contributors