fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Popular
    Log in to post
    • All categories
    • All Topics
    • New Topics
    • Watched Topics
    • Unreplied Topics
    • All Time
    • Day
    • Week
    • Month
    • TashaB

      How do I loop my EA?
      Questions & Answers • • TashaB

      49
      1
      Votes
      49
      Posts
      8034
      Views

      TipsyWisdom

      @ladydolares Id recommend you to youtube. My mentor is a controversial name but surely if you search around the internet you will find the person who didn't invent what an "order block" is, but made it widely known to the trading community back in the 90's. Or feel to message me and I can give you a good resource or 2

    • Monaco

      Expert programmer gives solutions to any problem just ask me
      Questions & Answers • • Monaco

      49
      0
      Votes
      49
      Posts
      7238
      Views

      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

    • T

      I need help on this
      Questions & Answers • • tec.nacks

      49
      0
      Votes
      49
      Posts
      2343
      Views

      T

      @tec-nacks I've figured it out realise I didnt place value on the string data type

    • tcanuto

      Problem with custom indicator ex5
      Bug Reports • • tcanuto

      48
      0
      Votes
      48
      Posts
      16435
      Views

      fxDreema

      108 and 117 are at the top.

      At the same time... if you use different Group number, this is like having different EAs, so in this case you can control 2 strategies at the same time in the same EA. This is the idea of the Group number.

    • Julianrob

      Profitable test results on Falcon and Condor, and forward testing looking good
      General Discussions • • Julianrob

      47
      0
      Votes
      47
      Posts
      7216
      Views

      thatguyisop

      @Julianrob Nice result on the Quant Analyzer! how is the progress on the live test so far? and is this an ORB-like strategy?

    • tcanuto

      My first EA FxDreema
      Questions & Answers • • tcanuto

      46
      0
      Votes
      46
      Posts
      18908
      Views

      tcanuto

      But unfortunately after having built, he did not open any order. This strategy I use on MT4 and redid all blocks in MT5. What should be happening? Please check if I messed up because I need something that works.

    • W

      A Place to discuss, optimize and share profitable Ea's?
      Questions & Answers • • wralyn

      46
      0
      Votes
      46
      Posts
      14635
      Views

      C

      @SirBoyce

      Hi,

      Can you share above improved project ?

      Best regards

    • R

      Gridding system
      Questions & Answers • • ramimoujaes

      46
      0
      Votes
      46
      Posts
      7085
      Views

      F

      Hi @ramimoujaes sorry I kwow that your post is quite very old. Are you still looking for a solution to your problem?

    • F

      Need help with EA based on indicator
      Questions & Answers • • facto

      46
      0
      Votes
      46
      Posts
      3348
      Views

      l'andorrà

      Then I'm afraid you will have to become a full subscriptor.

    • MTAB

      Pending order Stop Loss changes when it fills
      Questions & Answers • • MTAB

      46
      0
      Votes
      46
      Posts
      3534
      Views

      l'andorrà

      You're welcome.

    • tcanuto

      EA simple that works by the movement of the price.
      Questions & Answers • • tcanuto

      45
      0
      Votes
      45
      Posts
      16852
      Views

      tcanuto

      __It's close to impossible to calculate exact value of price distance. It's minimum 5 pips.[/quote:9e61omph]
      Ok This is what I needed to know. And that's what I really want in my strategy. Yes .. I've tried simple way, and the goal is this.

    • N

      Custom indicator values
      Questions & Answers • • nejaukais89

      44
      0
      Votes
      44
      Posts
      7088
      Views

      Y

      @timmyhanke said in Custom indicator values:

      Had a few indicators that repaints and the ea didnt even trade.
      So you better stick to something that dont repaint.

    • M

      Tutorial 07 - Read prices from indicator objects
      Tutorials by Users • • miro1360

      44
      9
      Votes
      44
      Posts
      23158
      Views

      S

      Using this for zone recovery might make sense

    • khalids222

      How can I find the average opening price for the last two positions?
      Questions & Answers • • khalids222

      44
      0
      Votes
      44
      Posts
      6374
      Views

      L

      @khalids222 I also think about the idea you think, but I can't do it.. I hope you can solve it... If you succeed, I ask you to share your project with us here, because we rookies who are eager to learn are looking forward to it. I wish you success....

    • C

      AND BLOCK
      General Discussions • • codex3024

      44
      0
      Votes
      44
      Posts
      2801
      Views

      jstap

      You have to decide what you're bot needs, there are countless reasons, so choose one.

    • H

      Library Studio
      Questions & Answers • • hilavoku

      43
      0
      Votes
      43
      Posts
      7594
      Views

      jstap

      Paste your cone here and say where you have added it, I'll have a look

    • S

      Manual Trailing stop loss
      Questions & Answers • • salahuddinonline

      43
      0
      Votes
      43
      Posts
      8423
      Views

      S

      @l-andorrà consider this one as my project,
      Custom trailing stop for every order,
      If you cant do it, some other one will help me doing this who knows how to do it,

      @miro1360 can you help on this ?

    • timmyhanke

      Find orders
      Questions & Answers • • timmyhanke

      43
      0
      Votes
      43
      Posts
      8301
      Views

      T

      137-1=136

    • S

      Need help in setting pending orders
      Questions & Answers • • styleflesh

      43
      0
      Votes
      43
      Posts
      3023
      Views

      D

      @styleflesh Pls can i see what you have done? i have issue creating on myself

    • N

      Martingale principles
      Questions & Answers • • NZEFILI

      43
      0
      Votes
      43
      Posts
      5115
      Views

      Abade69

      @AlphaOmega I agree that backtesting is not good enough by itself, but it's x1000 times better than just assuming (hoping) that something works and then put money into it without any kind of analysis.

      The way I judge experts now is not how good or bad these are in isolation, but how good they are in relation to each other in specific markets and situations, and how they would be able to complement each other when one of the pieces fail.

      Markets change constantly and rigid strategies lose their edge and start underperforming when new volatility and structure regimes arise. This is why we also have to adapt and improve our strategy continuously.

      The new AI technology will make trading A LOT harder than it already is.

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 9
    • 10
    • 4 / 10