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
Tiazo chrino 30 - 200 USD
Donc pour moi ça constite à faire de l'argent en ligne et faire aussi quelques pub en passant c'est toujours comme ça on y peut rien mais faire de l'argent c'est plus mieux je trouve
Need to make EA that make pending stop orders with grid steps with take profit and stoplos etc I need time filter and auto lots x balance also the stop order Must be replace when current order that was activated by the stop order has close
EA indicador Velas 30 - 50 USD
Necesito crear un EA basado en un indicador que da señal de entrada y que tenga los siguientes parametros 1. Entrar Buy o Sell en la siguiente vela de la señal dependiendo la Flecha 2. El TP para BUY sera apenas cierre en vela verde sin importar los pips que saque de ganancias puede ser que sea 1 pip o 10 o incluso salir en perdida, no importa 2. El TP para Sell sera apenas cierre en vela roja sin importar los pips
Sbhamu robot 50+ USD
The general robot trader is authorized with stock and strategies in market analysis. Robot trade profitable more income higher analysis and financial development and education management and management services and
I Need help from AI capable programmer to create a trade entering and managing system. I am today trading XAUUSD manually. I get my trading input from a signal provider. I get signals from this provider 5 to 7 times per day Same layout every time for this message that contains the signal. The signal is arriving to my telegram account, and I must set the trade at once if I want to follow from that trade-start
Forex trading market opening an account for the first time, modify you system of forex , always there for everyone,you are all welcome and for info on all platforms @ lil_johnny254 there to serve you
There is a indicator in Trading View called MavilimW Ortalamalari by Kivanc fr3762. I need same indicator for MT4 as a Expert Adviser. It should work certain hours of the day and any timeframe. When the green candle closed above the 3 red lines I want to be in a long position with one target and stop loss automatically. It shouldn't take many trade until the first trade finish
C onversion from Ninjatrader to Tradingview. This includes thorough testing and debugging to guarantee that the script functions as intended on Tradingview...If you are in for this job kindly bid
I need an urgent requirement by the developer who are able expert in designing the EA-Anil and can give best trailing result of profit in EA-Anil I am sending.Developer should design the best graphic user trader panel info, plus a buy sell input panel and should display trade result within 4-5 days of this development program
105fx 30 - 200 USD
We are trading nothing is a scam when you join our group we use same robot and we use the same broker we can also teach you some other tricks of trading

Project information

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