ryujin
-
Posts
60 -
Joined
-
Last visited
Content Type
Profiles
Forums
Articles
Posts posted by ryujin
-
-
Hi guys,
Below is the latest from cable run
======
/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : [email protected]
*/
//#import "MQ4Check.dll"
// int getKey1();
//#import
extern int Step = 170;
extern double FirstLot = 0.1;
extern double IncLot = 0.0;
extern int Magic = 2008;
extern string PlaceTradesFrom = "00:00";
extern string PlaceTradesTo = "23:59";
extern double MinProfit = 15.0;
extern string MaxLoss = "0=none; 1=pips (position with largest loss); 2=percent (all orders)";
extern int MaxLossMethod = 1;
extern int MaxLossPips = 100;
extern int MaxLossPct = 5;
double g_ord_lots_144 = 0.0;
double g_ord_lots_152 = 0.0;
double gd_160;
double gd_168;
int gi_176 = 16749022;
int gi_unused_180 = 1774;
int start() {
int li_0;
if (idCheck_unique() != 1) {
li_0 = MyOrdersTotal(Magic);
if (GetTotalProfit(Magic) >= MinProfit) {
DeletePendingOrders(Magic);
CloseOrders(Magic);
}
if (MaxLossMethod == 1 && GetMaxLossPips(Magic) >= MaxLossPips) {
DeletePendingOrders(Magic);
CloseOrders(Magic);
} else {
if (MaxLossMethod == 2 && GetTotalProfit(Magic) <= (-1.0 * AccountBalance()) * MaxLossPct / 100.0) {
DeletePendingOrders(Magic);
CloseOrders(Magic);
}
}
GlobalVariableSet("OldBalance", AccountBalance());
if (!IsInTimeWindow(PlaceTradesFrom, PlaceTradesTo)) {
if (li_0 > 0) DeletePendingOrders(Magic);
Comment("not in trading window");
} else {
Comment("in trading window");
if (li_0 == 0) {
OrderSend(Symbol(), OP_BUYLIMIT, FirstLot, Ask - Step * Point, 3, 0, 0, "", Magic, 0, Green);
OrderSend(Symbol(), OP_SELLLIMIT, FirstLot, Bid + Step * Point, 3, 0, 0, "", Magic, 0, Red);
}
gd_160 = GetLastSellPrice(Magic);
gd_168 = GetLastBuyPrice(Magic);
if (gd_160 - Bid <= 5.0 * Point) OrderSend(Symbol(), OP_SELLLIMIT, g_ord_lots_144 + IncLot, gd_160 + Step * Point, 3, 0, 0, "", Magic, 0, Red);
if (Ask - gd_168 <= 5.0 * Point) OrderSend(Symbol(), OP_BUYLIMIT, g_ord_lots_152 + IncLot, gd_168 - Step * Point, 3, 0, 0, "", Magic, 0, Red);
}
}
return (0);
}
int DeletePendingOrders(int a_magic_0) {
int l_ord_total_4;
if (idCheck_unique() != 1) {
l_ord_total_4 = OrdersTotal();
for (int l_pos_8 = 0; l_pos_8 < l_ord_total_4; l_pos_8++) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT) OrderDelete(OrderTicket());
}
}
return (0);
}
int CloseOrders(int a_magic_0) {
int l_ord_total_4;
if (idCheck_unique() != 1) {
l_ord_total_4 = OrdersTotal();
for (int l_pos_8 = 0; l_pos_8 < l_ord_total_4; l_pos_8++) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 3);
}
}
}
return (0);
}
int MyOrdersTotal(int a_magic_0) {
int l_count_4;
int l_ord_total_8;
if (idCheck_unique() != 1) {
l_count_4 = 0;
l_ord_total_8 = OrdersTotal();
for (int l_pos_12 = 0; l_pos_12 < l_ord_total_8; l_pos_12++) {
OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol()) l_count_4++;
}
}
return (l_count_4);
}
double GetLastBuyPrice(int a_magic_0) {
int li_4;
if (idCheck_unique() != 1) {
li_4 = OrdersTotal() - 1;
for (int l_pos_8 = li_4; l_pos_8 >= 0; l_pos_8--) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_BUYLIMIT || OrderType() == OP_BUY) {
g_ord_lots_152 = OrderLots();
return (OrderOpenPrice());
}
}
}
return (0);
}
double GetLastSellPrice(int a_magic_0) {
int li_4;
if (idCheck_unique() != 1) {
li_4 = OrdersTotal() - 1;
for (int l_pos_8 = li_4; l_pos_8 >= 0; l_pos_8--) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_SELLLIMIT || OrderType() == OP_SELL) {
g_ord_lots_144 = OrderLots();
return (OrderOpenPrice());
}
}
}
return (100000);
}
int GetMaxLossPips(int a_magic_0) {
int li_4;
int li_8;
bool li_ret_12;
if (idCheck_unique() != 1) {
li_ret_12 = FALSE;
li_4 = OrdersTotal() - 1;
for (int l_pos_16 = li_4; l_pos_16 >= 0; l_pos_16--) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_BUY || OrderType() == OP_SELL) {
if (OrderType() == OP_BUY) li_8 = Ask - OrderOpenPrice();
else li_8 = OrderOpenPrice() - Bid;
if (li_8 < 0 && MathAbs(li_8) > li_ret_12) li_ret_12 = MathAbs(li_8);
}
}
}
return (li_ret_12);
}
int GetTotalProfit(int a_magic_0) {
int li_4;
double ld_ret_8;
if (idCheck_unique() != 1) {
ld_ret_8 = 0;
li_4 = OrdersTotal() - 1;
for (int l_pos_16 = li_4; l_pos_16 >= 0; l_pos_16--) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_8 += OrderProfit();
}
}
return (ld_ret_8);
}
bool IsInTimeWindow(string as_0, string as_8) {
string l_time2str_16;
if (idCheck_unique() != 1) {
l_time2str_16 = TimeToStr(TimeCurrent(), TIME_MINUTES);
if (as_8 > as_0) return (l_time2str_16 >= as_0 && l_time2str_16 <= as_8);
}
return (l_time2str_16 >= as_0 || l_time2str_16 <= as_8);
}
int idCheck_unique() {
//if (getKey1() == gi_176)
return (0);
//return (1);
}
======
- TheBeast, tomislav, radicaltour and 4 others
- 7
-
I have post earlier a function for calculating the profit wich working for me with no problems, and i check with real and backtest and at predefined level it closes the trades.
for not put again, just please do a search in my previous post and you can use that function.
#post 204
regards,
Hi eggzactly,
I have insert your codes inside the EA. Just want to check with you if I am correct in the EA variables declaration and the function
int pmode;
double Pips = TotalProfit(pmode,Magic);
if (Pips >= MinProfit){
CloseAllTrades(0,Magic);
DeletePendingOrders(Magic);
}
Do I need to put
CloseAllTrades(1, Magic);
CloseAllTrades(2, Magic);
Since this is declare on top inside the init start()
What does CloseAllTrades(1, Magic); , CloseAllTrades(2, Magic); and CloseAllTrades(0, Magic); means?
-
Hi muruku,
I have tried your function
double Pips = TotalProfit(Magic);
if (Pips >= MinProfit){
CloseAllTrades(0,Magic);
DeletePendingOrders(Magic);
}
which called the function below.
int TotalProfit(int Magic)
{
int total=OrdersTotal();
int totalPips = 0;
for (int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
int mode=OrderType();
bool condition = false;
if (OrderMagicNumber()== Magic)condition = true;
if (condition)
{
switch (mode)
{
case OP_BUY:
totalPips += MathRound((MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT));
break;
case OP_SELL:
totalPips += MathRound((OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))/MarketInfo(OrderSymbol(),MODE_POINT));
break;
}
}
}
return(totalPips);
}
I observe my account which is floating more than $30 in profits, but the EA still did not closed all the trades?
By the way, my broker is a 5 digit no, hence, I change the value for step and MinProfit to be 170 and 150
int Step = 170; // org 17 .. still stick to 17
extern double FirstLot = 0.01; // org 0.10 .. risky .. so just put 0.1
double IncLot = 0.0; // org 0.0
double MinProfit = 150; // org 15
Would that be the cause to all orders not closed?
Hi eggzactly,
Do u think u can help with this?
-
Hi muruku,
I have tried your function
double Pips = TotalProfit(Magic);
if (Pips >= MinProfit){
CloseAllTrades(0,Magic);
DeletePendingOrders(Magic);
}
which called the function below.
int TotalProfit(int Magic)
{
int total=OrdersTotal();
int totalPips = 0;
for (int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
int mode=OrderType();
bool condition = false;
if (OrderMagicNumber()== Magic)condition = true;
if (condition)
{
switch (mode)
{
case OP_BUY:
totalPips += MathRound((MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT));
break;
case OP_SELL:
totalPips += MathRound((OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))/MarketInfo(OrderSymbol(),MODE_POINT));
break;
}
}
}
return(totalPips);
}
I observe my account which is floating more than $30 in profits, but the EA still did not closed all the trades?
By the way, my broker is a 5 digit no, hence, I change the value for step and MinProfit to be 170 and 150
int Step = 170; // org 17 .. still stick to 17
extern double FirstLot = 0.01; // org 0.10 .. risky .. so just put 0.1
double IncLot = 0.0; // org 0.0
double MinProfit = 150; // org 15
Would that be the cause to all orders not closed?
-
Hi muruku,
I have managed to resolve the problems. Thanks for all the mods.
-
bud, you have to brush out your mq4 scripting skill.
Do you think codes supplied here is plug & play ?
Hi muruku,
I am still learning the Mq4. Are you able to advise me what is wrong?
Thanks
-
Hi eggzactly,
I have insert your codes into the EA and have a warning when compiling the EA.
Function "TotalProfit" is not referenced and will be remove from exp-file
Is this expected?
-
Clevereto,
you can add this type of code if you want to test the close of pending orders if ATR out of boundaries :
in start put
if (ATROUT()==1) { OrderDeleteLimit();} // where ATROUT the function for check the ATR Limits
at the end of the file put
void OrderDeleteLimit()
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderCloseTime() == 0) {
if (OrderType() == OP_BUYLIMIT ||OrderType() == OP_SELLLIMIT) OrderDelete (OrderTicket());
}
}
}
------
if not orders at market, you can put this
if (ATROUT()==1) { "Time function not allowed to trade, like NY Session";} // where ATROUT the function for check the ATR Limits
Hope this helps
Regards,
eggzactly
HI Eggzactly,
I have tried putting your code inside the EA and faced errors. Can help to assist to put the codes inside the EA?
Thanks
-
Hi,
I have just checked my demo ac running this EA. There is a lot of error 130 for the EA to modify the orders?
====================================
02:52:46 CableRunII GBPUSDsf,H1: open #12963686 buy limit 0.01 GBPUSDsf at 1.56380 ok
03:02:37 CableRunII GBPUSDsf,H1: open #12963687 buy limit 0.01 GBPUSDsf at 1.56363 ok
03:03:46 CableRunII GBPUSDsf,H1: open #12963688 buy limit 0.01 GBPUSDsf at 1.56346 ok
03:03:46 CableRunII GBPUSDsf,H1: open #12963689 buy limit 0.01 GBPUSDsf at 1.56329 ok
03:36:37 CableRunII GBPUSDsf,H1: open #12963691 buy limit 0.01 GBPUSDsf at 1.56312 ok
03:38:12 CableRunII GBPUSDsf,H1: open #12963692 buy limit 0.01 GBPUSDsf at 1.56295 ok
04:01:13 CableRunII GBPUSDsf,H1: open #12963693 buy limit 0.01 GBPUSDsf at 1.56278 ok
04:01:13 CableRunII GBPUSDsf,H1: open #12963694 buy limit 0.01 GBPUSDsf at 1.56261 ok
04:09:15 CableRunII GBPUSDsf,H1: open #12963700 buy limit 0.01 GBPUSDsf at 1.56244 ok
04:53:13 CableRunII GBPUSDsf,H1: open #12963705 buy limit 0.01 GBPUSDsf at 1.56227 ok
04:53:13 CableRunII GBPUSDsf,H1: open #12963706 buy limit 0.01 GBPUSDsf at 1.56210 ok
04:55:41 CableRunII GBPUSDsf,H1: open #12963707 buy limit 0.01 GBPUSDsf at 1.56193 ok
04:57:29 CableRunII GBPUSDsf,H1: open #12963708 buy limit 0.01 GBPUSDsf at 1.56176 ok
06:05:49 CableRunII GBPUSDsf,H1: open #12963730 buy limit 0.01 GBPUSDsf at 1.56159 ok
07:20:00 CableRunII GBPUSDsf,H1: open #12963750 buy limit 0.01 GBPUSDsf at 1.56142 ok
07:27:25 CableRunII GBPUSDsf,H1: open #12963757 buy limit 0.01 GBPUSDsf at 1.56125 ok
07:29:58 CableRunII GBPUSDsf,H1: open #12963759 buy limit 0.01 GBPUSDsf at 1.56108 ok
07:31:55 CableRunII GBPUSDsf,H1: open #12963760 buy limit 0.01 GBPUSDsf at 1.56091 ok
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 0
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 1
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 2
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 3
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 4
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 5
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 6
07:44:12 CableRunII GBPUSDsf,H1: #12963681 Error: 130 Function: NewOrder(2,0.01,1.5609,0,0) 7
============================================================
Can someone fixed this?
-
Hi muruku,
I would like to know which part of the EA which I can control the number of pending orders?
By the way, I am able to use the EA to place micro lots on the trading account. I think need to adjust the value 17 to 170. But I am not at home now, later I would confirm again.
-
Hi guys,
I am right. This EA cannot trade on 5 digits brokers and cannot place 0.01 orders. Can someone made the mods on this EA to trade on 5 digit brokers and place 0.01 orders?
-
Hi all,
Would it be possible that this EA cannot trade in 5 digits brokers?? Just my wild guess... Anyone can take a look?
-
Hi richdad,
I have already change the maxspread to be more than 1 pips and there are still no trades. Also unable to do backtest as well. Would observe further as there are no further errors.
-
Hi all,
I have loaded the ea on live and demo ac for the past 4 hrs.
But there is no trades at all?? Does the dll needs to be educate?
-
hi,
can someone educate the dll to remove the restrictions. Thanks
-
hi guys,
Can someone pls share another upload link for this EA. Thanks
-
The timeframe to run is M15 based on the video in the website
-
No need to waste time on this EA. This EA is using martingale elements and would burst the ac sooner or later.
-
Hi,
I have download and install the Microsoft Visual C++ on my PC. But still getting the error 126? Can assist?
-
hi, please create demo ac for 2088218586
-
does anyone have the manual for this? can share
-
hi, can somone post the dll in 4shared or 2shared. cannot access sharebee
-
Hi,
I come across this EA on the youtube. (http://www.youtube.com/watch?v=O3XQ3kWtz5g)
Seems quite interesting
Does anyone have this set of EA?
-
Hi,
What pairs and time frame to run this EA?
Ea shark 6.0
in MetaTrader Expert Advisors Request
Posted
Hi,
Can you share this EA?
Thanks