Hedging Trading Robot coding required

Job finished

Execution time 2 days

Specification

I am looking to have the below code cleaned up and formed into an ex4. I am getting a headache trying to do this myself.


This is a continuing project and I would like to continually develop and improve this EA.


The logic for this EA is as follows

*initiate trade everyday at 23:00 GMT or 1:00 PST.

*initiate a hedge by putting on both a long and a short order.

*set a 20pip Take Profit and a 100pip Stop Loss on both orders.

*Initial lot size = (account balance/100,000). As an example, if the account balance is $10,000 then the lot size would equal .1.

*If the previous trade resulted in a profit then keep the lot size at(account balance / 100,000) However, If the previous trade resulted in a loss then adjust the lot size to (account balance/20,000) so now a $10,000 account would have a lot size of .5




input int start_hour = 23;
input int start_minute = 0;
input int end_hour = 0;
input int end_minute = 0;
input int take_profit = 20;
input int stop_loss = 100;
input int winning_denom = 100000;
input int losing_denom = 20000;
input string order_comment = *EA20 Fresh Start*;
input int signal_bar = 0;

int magic_number;
int fract_factor = 1;
int OnInit (){
magic_number = (int) TimeCurrent ();
if (Digits == 5 || Digits == 3) fract_factor = 10;
Print (*EA20 is initialized. Magic number is *+ (string)magic_number);
return (INIT_SUCCEEDED);
}

void OnTick(){
static datetime last_open_signal_time = 0;
if (OpenSignal (signal_bar) ++ Time [0] ! = last_open_signal_time) {
Order (OP_BUY);
Order (OP_SELL);
last_open_signal_time = Time [0];

}

static datetime last_close_signal_time = 0;
if (CloseSignal(signal_bar)++ Time [0] ! = last_open_signal_time){
CloseAllTrades();
last_close_signal_time = Time [0]

}
}

void OnDeinit (const int reason) {
}

double GetLastTradeProfit(){
double profit = EMPTY_VALUE;
datetime close_time = 0;
for (int i = OrdersHistoryTotal() - 1; i > = 0; i --)
if (OrderSelect(i, SELECT_BY_POS_MODE_HISTORY))
if (OrderMagicNumber() == magic_number ++ OrderCloseTime()> close_time){
}
return profit;
}

void CloseAllTrades (int order_type =-1){
for (int i = OrdersTotal() -1; i >= 0; i --)
if (OrderSelect(i, SELECT_BY_POS))
if ((OrderType() <= 1 ++ order_type ==-1) || (OrderType () == order_type))
if (OrderMagicNumber () == magic_number)
if
(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(), 10* fract_factor, clr NONE))
Print (GetLastError());
}

int Order (int order_type) {
double price = (order_type == OP_BUY) ? Ask: Bid;
double tp = (take_profit == 0)? 0: (order_type == OP_BUY)? price + take_profit* Pip(): price - take_profit * Pip();
double sl= (stop_loss == 0)?0: (order_type == OP_BUY)? price - stop_loss * Pip(): price + stop_loss * Pip();
double denom = (GetLastTradeProfit() == EMPTY_VALUE)? winning_denom: (GetLastTradeProfit() > 0)? winning_denom: losing_denom;
double lot = AccountBalance()/denom;
double min_lot = Market_Info(Symbol(),MODE_MINLOT);
lot= NormalizeDouble (lot,1);
lot= MathMax (min_lot, lot);
return
OrderSend(Symbol(), order_type,lot,price,10,sl,tp, order_comment, magic_number,0,clr NONE);
}

double Pip(){
return Point * fract_factor;
}

bool OpenSignal (int shift) {
if (TimeHour(Time[shift]) == start_hour ++ TimeMinute(Time[shift]) == start_minute)
return true;
return false;
}

bool CloseSignal (int shift){
if (TimeHour(Time[shift]) == end_hour ++ TimeMinute(Time[shift]) == end_minute ++ (end_hour ! = 0 || end_minute ! = 0))
return true;
return false;
}

Responded

1
Developer 1
Rating
(253)
Projects
358
49%
Arbitration
24
25% / 50%
Overdue
80
22%
Free
2
Developer 2
Rating
(117)
Projects
138
41%
Arbitration
30
7% / 77%
Overdue
17
12%
Free
3
Developer 3
Rating
(35)
Projects
40
23%
Arbitration
10
10% / 50%
Overdue
16
40%
Free
4
Developer 4
Rating
(89)
Projects
137
24%
Arbitration
35
9% / 40%
Overdue
52
38%
Free
5
Developer 5
Rating
(219)
Projects
370
42%
Arbitration
145
17% / 41%
Overdue
124
34%
Free
6
Developer 6
Rating
(53)
Projects
74
26%
Arbitration
30
10% / 63%
Overdue
22
30%
Free
7
Developer 7
Rating
(298)
Projects
427
26%
Arbitration
18
61% / 33%
Overdue
26
6%
Free
Similar orders
I'm a professional trader looking to see how much a bot would cost. This method is profitable and tested like my other 7 other systematic methods that are created already. the method consists of a range being broken high or low and enters on a reversal sign. The method uses fractals, set pip distance tp with set tp stop loss. There will be more work if this relationship goes well. Thank you
Hey, I would like to run EA on muliple symbols and on each symbol can have different preset depending on strategy optimation. It should run on MT5. == I am a beginner in mql5, tried to write it on my own so some code exists, but open positions on the next opened bar, and trailing stop is fixed, not ATR based. It calculates SL as % of risk but doesn't work when position size is bigger than balance allows (so no max
I need a programmer that can teach me how to get historical tick data (from predownloaded csv) and make it display when back-testing in the MT4 terminal. What I need from you is to build a panel that reads in the ticks from a predefined start time up to and including the current time of the back-test. It needs to: 1. Count the total number of ticks from the predefined start time. 2. Display the current tick's ask
Hey, im looking for a person who can create an my very own version of pineconnector, which should have all the option of pineconnector and it should be user-friendly without any complications
HI, I'm looking for an experienced person who can add buy/sell indications and Alerts on existing Pinescript along with little modification of the script and the script should connect to MT5 platform using pineconnector MT5 platform should excute trade instantly as based on the alerts/indications on tradingview script
We are seeking a highly experienced Forex EA Developer for our MT4 platform. The ideal candidate must meet our following criteria: Language Proficiency: Must speak English fluently - no exceptions Must write in English proficiently - no exceptions Must understand English clearly - no exceptions Availability: Must work in the Eastern Standard Time (EST) zone Developer must be available full-time for this project with
Requirements All features of indicators, plus enter into trades (buy, sell) TP and SL according to the indicator [TP1 and TP2] Can make MT5 from MT4 indicator? Add trailing stop loss trading hours trading days Max spread Possibility of Multiple charts through one window Daily profit Target [yes/no]
hello... saya menginginkan EA GRID?AVERAGING dengan kondisi : > bisa meletakan sell&buy Limit pada nilai tertentu > bisa meletakkan sell&buy stop pada nilai tertentu > bisa melakukan order sell/buy limit/stop (sesuai setting) berdasarkan Nilai RSI > bisa membatasi jumlah order > ada fungsi TP dan SL > rangkuman hasil kerja EA selama mingguan terimakasih, semoga bisa bekerjasama dengan baik
I already have the EA completed. I just need to add 2 params and fix the feature (GV) to make sure that no order is missed for any reason. Maybe GV is not enough and need to add another feature
Need to create ea to trade in indian market by placing orders to Indian market platform through API form mqlHere's a basic outline of what script should include: Define Heikin Ashi candle pattern: Convert regular candles to Heikin Ashi candles. Order Execution: Execute orders on the open of the second candle after the signal is generated. Buy Call: When a buy call is generated, initiate a call option order. Set

Project information

Budget
50 - 1000 USD
For the developer
45 - 900 USD