작업 종료됨
실행 시간 3 일
고객의 피드백
Super genius and super fast
피고용인의 피드백
5 star client!
Happy to have worked with Naresh.
명시
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; } } }
응답함
1
등급
프로젝트
23
0%
중재
6
17%
/
83%
기한 초과
2
9%
무료
2
등급
프로젝트
62
40%
중재
1
0%
/
100%
기한 초과
7
11%
작업중
3
등급
프로젝트
242
45%
중재
18
78%
/
17%
기한 초과
35
14%
작업중
4
등급
프로젝트
181
24%
중재
23
22%
/
39%
기한 초과
13
7%
무료
5
등급
프로젝트
133
35%
중재
13
38%
/
31%
기한 초과
32
24%
무료
6
등급
프로젝트
1
0%
중재
2
0%
/
100%
기한 초과
0
무료
7
등급
프로젝트
777
46%
중재
23
39%
/
13%
기한 초과
63
8%
작업중
8
등급
프로젝트
28
32%
중재
1
0%
/
0%
기한 초과
0
무료
9
등급
프로젝트
239
70%
중재
3
67%
/
33%
기한 초과
20
8%
무료
비슷한 주문
I want grate robot for making profits
30 - 200 USD
I want grate robot for making profits that know when to start a good trade and close a trade and must be active all time to avoid lost of money
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
Mbeje fx
50+ USD
I like to own my robot that why I want to build my own.i like to be a best to every robot ever in the life to be have more money
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
프로젝트 정보
예산
30+ USD
개발자에게
27
USD
기한
로 2 일