The goal here is to get trades opened at or near support and resistance levels and allow the user to manually trail until the market takes out the trade. Use of take profit will be rare and only in sideways markets. I have something similar but this has enough changes in the logic to justify building a whole new EA with code the programmer is familiar with. All we would be able to keep is the Magic number and some of the trigger coding which is not so difficult to put together again.
User can draw horizontal lines on MT4 chart with EA and EA will incorporate those lines as trade levels. Additionally i would like to add an offset variable so that the trades do not happen on each line but a user defined distance from each line. There still needs to be a trigger distance to determine the market is moving in the desired direction with enough momentum to justify the trade. Essentially this is grid strategy but the levels reactivate them selves based on user drawn lines.
Proposed Logic:
M = Magic #
SL=Stop loss
BE=Break even trigger
BEP=Break even (pips)
IS=initial stop loss
ED=trigger distance
ER=Extra risk management
P@=price at tick (current price)
BP=buy price
SP=sell price
HLA=Horizontal line above current price
HLB=Horizontal line below current price
IT=Incremental trail
OS:Offset
New trade logic
if HLA-ED-OS>P@ then buy at HLA=yes
Buy at HLA=yes/no (once this changes to yes it will stay yes until the level is triggered or the EA is removed from the chart)
if HLB+ED+OS<P@ then sell at HLB-=yes
Sell at HLB=yes/no (once this changes to yes it will stay yes until the level is triggered or the EA is removed from the chart)
if ER=no then ER=0 always
if ER=yes then check for open trades when level is reached Only place a new trade if all buy stop losses > buy price AND all sell stop losses < sell price result =ER
if ER>0 no trades can be placed
if P@=HLA +OS (+/- Slippage) AND buy at HLA=yes AND ER=0 place buy trade
if P@=HLB -OS (+/- Slippage) AND sell at HLB=yes AND ER=0 place sell trade
Open trade management logic
if P@>BP+BE AND SL<BP+IS move stop loss to BEP
if P@<SP-BE AND SL>BP-IS move stop loss to BEP
if IT=yes any time a stop loss is moved all trades with same M will have the same stop loss.
Trade Preperation Logic:
Lot size = equity*risk%/initial hedge
stop loss = entry price +/- initial stop loss
take profit = Take prfit if >0
user set variables:
MAGIC NUMBER: so that the same EA can be run on multiple pairs
RISK %: The lot size should be calculated using Equity *(risk%*.01)/initial hedge. In the example if its a $2500.00 account with no open trades it would be 2500*.02= 50/25=2*0.1= 0.2 lot size. This will allow the value to change at the time of trade according to current equity. It will be important when trading multiple pairs.
EXTRA RISK MANAGEMENT (Yes/No):If no this sequence is skipped. If yes Before a new trade is placed it needs to check all open trades regardless of magic number and verify that buy trades have stop losses > entry and sell trades have stop losses < entry. Only 1 open trade should ever be at risk. if there is already an open trade that has not moved to break even or better then no new trade should be placed. This functions independant of Incrimental trail as all trades move to break even when trigger is reached.
TRIGGER DISTANCE: distance from line where the trade becomes active. While i do not want to use pending orders i do want the EA to act as though they are pending orders set when the level is further away than the LEVEL TRIGGER DISTANCE. For examle if there is a resistance level at 1.11250 and the trigger distance is set to 25 pips then if the market is already at 1.11010 and moving up the trade will never take place but if the market falls below 1.11000 then moves back up the level will be active and a trade will be taken at 1.11250. If it were a pending trade the trade would be created any time the market falls below 1.11000.
BREAK EVEN TRIGGER (pips): a # in pips at which point the stop loss will be moved to break even. This needs to be persistant so if the user accidently moves a break even to a losing position it will move back. however the logic sould dictate that it will not move any stop loss moved to a more proffitable position than the initial break even.
SLIPPAGE (pips): # in pips in case the market is really moving at the time the trade is taken.
BREAK EVEN (pips): a # in pips to define what break even is.
INITAL STOP LOSS (pips): a # in pips to determine how far from the trade the initial stop loss is placed
OFFSET: a # in pips away from the level at which a trade would be taken. This makes space for peak overs. example if this is set to 10 and there is a level at 1.25000 then the buy would be activated at or below 1.24750 and the buy would be entered at 1.25100. All other variables are based on actual entry level of the trade so they would enter based on the 1.25100 price for a buy.
TAKE PROFIT (optional): there may be times when i want to set a take profit for each trade this is where it would be done. 0= let it run without take profit. but it could be set at any # in pips.
INCREMENTAL TRAIL (Yes/NO): This is a yes or no option. If it is yes then any stop loss that is moved by the EA will move stops for all open trades with the same MAGIC NUMBER to the newest position.
Detailed example : Using real data from gbpjpy 4 hours candles assuming 25 pips for all triggers as well as initial stop loss and 3 pips for break even.4-5-18 to 4-18-18 levels at 150.389, 152.001, 153.460. Market opens at 150.350 this is near a line but too close so no HL+=no there is not trade at 150.350 the line may as well not exist.The market moved down over the next 4 hours to 28 pips, when it crosses 25 below the level them HL+=YES a buy trade at 150.350 will be taken the next time the price touches it. 8 hours later it crosses that level and a BUY market order is placed with a stop loss set 25 pips down. At this point as HL+ = 152.001 and YES and 150.350 is HL-=NO.During the next 4 hours the market draws down but not to 25 pips so the trade is still active. About 6 hours after the trade is taken the trade reaches 25 pips profitable and the stop loss is moved to 3 pips (break even) and HL-=yes@ 150.389. Over the next 2 days the market continually moves up and down but not quite low enough to stop out the trade. The user may have caused a stop out by manually trailing but for this example assume the trade is still active on 4-10-18 when between midnight at 3am the market crosses the 152.001 level which has been HL+=yes since the prevous trade stop loss was moved to 3 pips profitable and so a new buy trade is triggered. This buy trade triggers and since Incremental Trail is on both trades set their stop losses at 151.751 and during the next 4 hours both trades stop out one losing 25 pips and the other in profit 135 pips. 8 hours later the market has moved down 30 pips causing HL+=YES again at the same level and then moved back up triggering another buy. This time it goes up just enough to move to break even as well as activating the same level as a sell and then it goes back down and closes the buy trade and triggering the sell. on 4-12-18 the market goes back up closing the sell trade at break even assuming again that the user did not manually trail to get some profit out of the downard move. The buy is triggered again. This time over 24 hours it moves up to trigger the next level crossing it and then coming back down after going 40 pips past the entry and triggering the move to break even moving both stop losses first to the 25 pips below and then to 3 pips in profit for the most recent trade. The market then comes back 4 hours later and stops out both trades. This also triggers the sell trade that was activated when the buy trade moved 25 pips profitable. The market then moves down 70 pips activating the sell and moving the stop to break even. This is where the example ends but i'm sure you get the picture.
Similar orders
Ai 1. Trend identify up or down through lMA 50 at daily time frame ( if market stay above LMA 50 is called up trend & stay down lMA is called Down trend. 2. Entry :for uptrend buy & down trend sell though cross over lMA 50by21 & 21 by 14or7 ( customisable )1m or 5m flexible time 3. Daily target Floating loss (DD) if over no entry as % - close all 4. TP, break even after 2 pips (customisable)& SL option
//+------------------------------------------------------------------+ //| XAUUSD FULL AUTO SAFE BOT MT5 | //| Converted from Pine Script v5 | //+------------------------------------------------------------------+ #property copyright "Converted by ChatGPT" #property version "1.00" #property strict #include <Trade/Trade.mqh> CTrade trade; // === INPUT === input double LotPercent =
//+------------------------------------------------------------------+ //| XAUUSD H1 Auto Trading Bot | //| Works on MT5 Desktop / VPS | //+------------------------------------------------------------------+ #property strict input double LotSize = 0.1; input int StopLossPoints = 200; input int TakeProfitPoints = 400; input int MagicNumber = 777; int emaHandle;
Trading robots are programs, which operate according to underlying algorithms. An algorithm is a set of actions that need to be performed in response to certain events. For example, the most common task in algo trading is the identification of the "New bar" event. When the event occurs, the robot checks the emergence of trading signals and acts accordingly. Before you decide to program or order a trading robot, you
// Add this to your EA after ExportState() function void SendToBase44(const string state, const string dir, double entry, double sl, double tp) { string url = " https://preview-sandbox--ee0a32a725b788974de435e8cef40b7a.base44.app/api/functions/receiveEAState "; string headers = "Content-Type: application/json\r\n"; string json = "{" "\"symbol\":\""+_Symbol+"\","
I need a prop firm ready EA that can make around 3% monthly. I am not expecting miracles, If you want to apply please send me backtesting stats from at least few years. 1 year is not enough, I am ready to sign in an agreement today
Develop a Gold scalper based on the arrow indicator in MT5. Buy at up arrow and close with the profit / Trailing Stop profit. If not profit, then close at the opposite sell arrow with profit/loss. Sell at down arrow and close with the TP / Trailing Stop profit. If not profit, then close at the opposite buy arrow with profit/loss. EA Properties: Lot Size: 0.1 Stop Loss: 0 / 50 Take Profit: 100 Trailing Start: Trailing
Hi, looking for an EA for passing prop accounts, profit target is 2,5% weekly with low drawdown, strict risk management, session filters, spread control, automatic stop, daily loss limits, VPS compatibility, reporting, and consistent performance across EURUSD in market conditions
We already have the strategy. Need an MT4 Expert Advisor to set up on MT4 platform from MQL5. Tasks 1.Check why AutoTrading/EA is not executing trades 2. Verify MT4 settings 3. Install/compile an EA file if needed and confirm it runs
Hello! I am looking for an experienced, top-rated developer to build highly profitable strategy software that provides accurate signals for both long-term and short-term trades. The software must analyse the market correctly, indicating when to enter and where to set Take Profit (TP) and Stop Loss (SL) levels. It must deliver accurate results across all markets, including Forex, cryptocurrencies, metals, indices, and