Job finished
Execution time 3 days
Feedback from customer
Super genius and super fast
Feedback from employee
5 star client!
Happy to have worked with Naresh.
Specification
I need to modify my script to create a loop to check the buy and sell orders profit separately. close when 1st buy order and last buy order's average is profit.
Currently, my code closes all the buy/sell order's average is in profit. I would like to modify that for buy and sell orders.
//+------------------------------------------------------------------+ //| CloseOnAverage.mq4 | //| Copyright 2021, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict extern int Choose_stragegy=1; // 1-hedging 2-trend input int InpMaxTrades = 10; // Max number of trades input double InpTradeGap = 0.005; // Distance between trades //input ENUM_ORDER_TYPE InpType = ORDER_TYPE_BUY; // Order type;// input double InpMinProfit = 1.00; // Profit point input int InpMagicNumber = 1111; // Magic number input double Multiplier = 2; input string InpTradeComment = __FILE__; // Trade comment input double InpVolume = 0.01; // Volume per order double pips; //double multi= (InpVolume*Multiplier); struct STradeSum { int buycount; int sellcount; double buyprofit; double sellprofit; double buytrailPrice; double selltrailPrice; }; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void OnTick() { STradeSum sum; GetSum(sum); if (sum.buyprofit>InpMinProfit) { // target reached CloseAll(ORDER_TYPE_BUY); } if (OrdersTotal()>=3) { drawdownreduction(); } else if (sum.sellprofit>InpMinProfit) { // target reached CloseAll(ORDER_TYPE_SELL); } else if (sum.buycount==0) { // no buy trades OpenTrade(ORDER_TYPE_BUY); } else if (sum.sellcount==0) { // no sell trades OpenTrade(ORDER_TYPE_SELL); } else if ((sum.buycount<InpMaxTrades)) { if ( OrderType()==ORDER_TYPE_BUY && SymbolInfoDouble(Symbol(), SYMBOL_ASK)<=(sum.buytrailPrice-InpTradeGap)) { // Far enough below OpenmultiTrade(ORDER_TYPE_BUY); } else if ((sum.sellcount<InpMaxTrades)) { if ( OrderType() ==ORDER_TYPE_SELL && SymbolInfoDouble(Symbol(), SYMBOL_BID)>=(sum.selltrailPrice+InpTradeGap)) { // Far enough above OpenmultiTrade(ORDER_TYPE_SELL); } } } //else if (sum.sellcount<InpMaxTrades) } //+------------------------------------------------------------------+ void OpenTrade(ENUM_ORDER_TYPE InpType) { double price = (InpType==ORDER_TYPE_BUY) ? SymbolInfoDouble(Symbol(), SYMBOL_ASK) : SymbolInfoDouble(Symbol(), SYMBOL_BID); OrderSend(Symbol(), InpType, InpVolume, price, 0, 0, 0, InpTradeComment, InpMagicNumber); } //+------------------------------------------------------------------+ void OpenmultiTrade(ENUM_ORDER_TYPE InppType) { double price = (InppType==ORDER_TYPE_BUY) ? SymbolInfoDouble(Symbol(), SYMBOL_ASK) : SymbolInfoDouble(Symbol(), SYMBOL_BID); double multi = (InpVolume*Multiplier); OrderSend(Symbol(), InppType, multi, price, 0, 0, 0, InpTradeComment, InpMagicNumber); } //+------------------------------------------------------------------+ void CloseAll(ENUM_ORDER_TYPE orderType) { int count = OrdersTotal(); for (int i = count-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if ( OrderSymbol()==Symbol() && OrderMagicNumber()==InpMagicNumber && OrderType()==orderType ) { OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0); } } } } //+------------------------------------------------------------------+ void GetSum(STradeSum &sum) { sum.buycount = 0; sum.buyprofit = 0.0; sum.buytrailPrice = 0.0; sum.sellcount = 0; sum.sellprofit = 0.0; sum.selltrailPrice = 0.0; int count = OrdersTotal(); for (int i = count-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { //Buy orders if (OrderSymbol()==Symbol() && OrderMagicNumber()==InpMagicNumber && OrderType()== ORDER_TYPE_BUY) { sum.buycount++; sum.buyprofit += OrderProfit()+OrderSwap()+OrderCommission(); if (sum.buytrailPrice==0 || OrderOpenPrice()<sum.buytrailPrice) { sum.buytrailPrice = OrderOpenPrice(); } } //sellorders if (OrderSymbol()==Symbol()&& OrderMagicNumber()==InpMagicNumber && OrderType()==ORDER_TYPE_SELL) { sum.sellcount++; sum.sellprofit += OrderProfit()+OrderSwap()+OrderCommission(); if (sum.selltrailPrice==0 || OrderOpenPrice()>sum.selltrailPrice) { sum.selltrailPrice = OrderOpenPrice(); } } } } return; } //+------------------------------------------------------------------+ //found this code online. The below code compares and closes the last two orders void drawdownreduction() { int slippage=10; double minimum_profit=InpMinProfit; int x; double trades[][4]; int total=OrdersTotal(); if(total>1) { ArrayResize(trades,total); for(x=total-1;x>=0;x--) { if(OrderSelect(x,SELECT_BY_POS,MODE_TRADES)) { trades[x][0]=OrderTicket(); trades[x][1]=OrderProfit()+OrderCommission()+OrderSwap(); trades[x][2]=OrderLots(); trades[x][3]=OrderType(); } } ArraySort(trades,WHOLE_ARRAY,0,MODE_ASCEND); x=0; while(x<total-1) { double profit=trades[x][1]+trades[total-1][1]; if(profit>=minimum_profit) { RefreshRates(); double close_price=Ask; if(trades[x][3]==OP_BUY) close_price=Bid; if(!OrderClose((int)trades[x][0],trades[x][2],close_price,slippage,clrNONE)) Print("Error closing #",DoubleToStr(trades[x][0],0)," Error code ",GetLastError()); RefreshRates(); close_price=Ask; if(trades[x+1][3]==OP_BUY) close_price=Bid; if(!OrderClose((int)trades[x+1][0],trades[x+1][2],close_price,slippage,clrNONE)) Print("Error closing #",DoubleToStr(trades[x][0],0)," Error code ",GetLastError()); } x+=2; } } }
Responded
1
Rating
Projects
23
0%
Arbitration
6
17%
/
83%
Overdue
2
9%
Free
2
Rating
Projects
62
40%
Arbitration
1
0%
/
100%
Overdue
7
11%
Working
3
Rating
Projects
242
45%
Arbitration
18
78%
/
17%
Overdue
35
14%
Working
4
Rating
Projects
181
24%
Arbitration
23
22%
/
39%
Overdue
13
7%
Free
5
Rating
Projects
133
35%
Arbitration
13
38%
/
31%
Overdue
32
24%
Free
6
Rating
Projects
1
0%
Arbitration
2
0%
/
100%
Overdue
0
Free
7
Rating
Projects
777
46%
Arbitration
23
39%
/
13%
Overdue
63
8%
Working
8
Rating
Projects
28
32%
Arbitration
1
0%
/
0%
Overdue
0
Free
9
Rating
Projects
239
70%
Arbitration
3
67%
/
33%
Overdue
20
8%
Free
Similar orders
I need an MT5 EA that can do the following: I have to give the EA a price in advance, when the price is reached the EA has to automatically place a buy stop or sell stop order 0.5 pips below or above the price. Is this possible
Dr Pattern
30+ USD
good day i need the service of the seaso coder to help me fix my ea The Job required 1 knowledge of Mt4 and Mt5 indicator coding 2. Telegram code 3. ability to code indicator to work on multiple Time frame combine to trade 4 Ability to Join two or three indicator on same ir different time frame if you have these skill please let chart i will discuss the details of the Job inside to you The required day including
Good day, I want someone to help me create a universal news filter with on/off switch, with start and end settings, and drawdown control with magic number of EAs, etc. Thanks
Integrate an existing mt4 EA with chatgpt
50 - 150 USD
Hello, I am looking for a professional programmer to optimize my existing EA integrating it with ChatGPT to analyze currencies using various methods to make the right trading decisions. i want it to be an EA that can be trusted to carry trade with the help of chat gpt and also have a very low drawdown
Hello, I am looking for a professional programmer to create a trading expert on the MT4 platform, integrating it with ChatGPT to analyze currencies using various methods to make the right trading decisions. Further details will be provided to the applicants later
MT5 code matches your TradingView strategy.
30 - 40 USD
I have developed a very strong TradingView strategy in Pine Script but unfortunately, a third-party connector is requiired and in my opinion, I want a more direct connection. I am not brilliant at coding, but I have coded the majority of the MT5 code and I would like you to make sure that the MT5 code matches my TradingView script and executes the same way as the TradingView script that I will provide if you are
EA based on RSI and MA
100 - 400 USD
Program is based on RSI and MA indicators dynamic as triggers, for Open/Close criteria. Runs automatically but inputs can be updated manually. It uses a GUI to manage it. Multi TF analysis. Log register of every operation for analysis (db) Open Source deliver. Kindly apply IF you have previous experience with trading and mql/python/c bot/algo developing. And if you have a good track record . ps: Better if you have a
This is and EPA (Entry Point Analyzer). Automatically analyzes the algorithm for XAU/USD and places a safe entry point mark for your trade. This has been tested and gives out 90% success rates
I am looking for an experienced MQL5 developer to help me finalize and optimize an Expert Advisor (EA) for the FTMO challenge. I have already built a significant portion of the code, but it requires further refinement and optimization to ensure it functions according to the trading strategy I intend to use. I am happy to share all the resources, including the current code, reference materials, and detailed
Lucy spontenious trade
50+ USD
dreams good and have a great Cash out from your smart phone , tuyoywuiy glamorous flood see full idk idk slow so dolls stupid sis workouts who's spark koalas oral waits also doggo idk
Project information
Budget
30+ USD
For the developer
27
USD
Deadline
to 2 day(s)