Jump to content

(Req) News Trading EA need to remove limitation demo only


asp1r3

Recommended Posts

Hello everybody,

 

I just found an ea specifically for news trading from other forum, that will place pending orders (sell stop and buy stop) right before the (big) news coming. I find this ea very useful instead of placing pending orders manually before the news. Unfortunately, it has restriction for demo only. Perhaps some coders / programmers could help to remove the restriction and make it running on live account. other fine tuning useful for news trading would be highly appreciated. Hope this simple EA is still relevant for this room of discussion.

 

here is the link of the demo news trading ea:

 

http://[email protected]/file/142334622/46a84bb5/Shihyou_v11.html

 

Following is the setting detail from the creator:

 

Initial parameters are belows.

 

MAGIC=magic number, should be unique for each currency pair.

Use_MM=if you want to use money management function, should be true.

LotsPercent=when Use_MM is true, determine use percentage of account free amount.

Use_Lots=when Use_MM is false, determine position volume.

Slippage=determine acceptable slipppage. (pips)

Stoploss=determine stoploss for each position. (pips)

Take_Profit=determine take profit for each position. (pips)

Trigger=important parameter, determine the clearance of quote and sellstop and buystop positions. if this value is too small, easy to take actual positions react small waves, if this value is too big, do not react even economic indicator make big trand. I recommend to use initial setting, 15pips.

Use_Trailstop=if you want to choose trailing stop function, should be true.

Trail=when Use_Trailstop is true, determine trailing stop value. (pips)

Repetable=After close sell or buy position, take sellstop and buystop position again, should be true.

 

Notice: Recommend to set this EA before 5 minutes of important economic indicator announcement time and stop EA, delete all of sellstop and buystop positions before closing MT4.

Link to comment
Share on other sites

Re: (Req) News Trading EA need to remove limitation demo only

 

#property copyright "Copyright2009, Eiji Niino"

#property link ""

 

extern int MAGIC = 3580358;

extern bool Use_MM = TRUE;

extern double LotsPercent = 25.0;

extern double Use_Lots = 0.1;

extern int Slippage = 20;

extern int Stoploss = 20;

extern int Take_Profit = 150;

extern int Trigger = 15;

extern bool Use_Trailstop = TRUE;

extern int Trail = 20;

extern bool Repeatable = TRUE;

double g_ord_takeprofit_128 = 0.0;

int gi_136;

bool gi_140 = TRUE;

 

int CalculateCurrentOrders() {

int l_count_0 = 0;

for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {

if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) {

if (OrderType() == OP_BUY) l_count_0++;

if (OrderType() == OP_SELL) l_count_0--;

}

}

return (l_count_0);

}

 

int CalculateBuyStopOrders() {

int l_count_0 = 0;

for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {

if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC)

if (OrderType() == OP_BUYSTOP) l_count_0++;

}

return (l_count_0);

}

 

int CalculateSellStopOrders() {

int l_count_0 = 0;

for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {

if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC)

if (OrderType() == OP_SELLSTOP) l_count_0++;

}

return (l_count_0);

}

 

int start() {

double ld_20;

int li_28;

double l_lots_32;

int lia_52[10];

int lia_60[10];

int lia_68[10];

int lia_76[10];

}

int li_0 = 1609372800;

 

}

double l_minlot_4 = MarketInfo(Symbol(), MODE_MINLOT);

double l_maxlot_12 = MarketInfo(Symbol(), MODE_MAXLOT);

if (AccountCompany() == "Fortune Capital Co. Ltd") ld_20 = MarketInfo("USDJPYFXF", MODE_BID);

else {

if (AccountCurrency() == "USD") ld_20 = 1;

if (AccountCurrency() == "JPY") ld_20 = MarketInfo("USDJPY", MODE_BID);

if (AccountCurrency() == "EUR") ld_20 = 1 / MarketInfo("EURUSD", MODE_BID);

if (AccountCurrency() == "GBP") ld_20 = 1 / MarketInfo("GBPUSD", MODE_BID);

if (AccountCurrency() == "CHF") ld_20 = MarketInfo("USDCHF", MODE_BID);

}

if (l_minlot_4 == 1.0) li_28 = 0;

if (l_minlot_4 == 0.1) li_28 = 1;

if (l_minlot_4 == 0.01) li_28 = 2;

if (Digits > 3) gi_136 = MathPow(10, Digits - 4);

else gi_136 = MathPow(10, Digits - 2);

if (Use_MM == TRUE) l_lots_32 = NormalizeDouble(AccountBalance() * LotsPercent / 100000.0 / ld_20, li_28);

else l_lots_32 = Use_Lots;

if (l_lots_32 < l_minlot_4) l_lots_32 = l_minlot_4;

if (l_lots_32 > l_maxlot_12) l_lots_32 = l_maxlot_12;

int li_40 = CalculateCurrentOrders();

int li_44 = CalculateBuyStopOrders();

int li_48 = CalculateSellStopOrders();

Comment("LOTS=", l_lots_32, " ", "Position(+1=Buy -1=Sell)=", li_40,

"\n", "Spread=", Ask - Bid,

"\n", "Min_lot=", l_minlot_4,

"\n", "Max_lot=", l_maxlot_12,

"\n", "AccountCompany=", AccountCompany(),

"\n", "AccountCurrency=", AccountCurrency(),

"\n",

"\n", "POWERED BY albirex7");

if (li_40 > 0 && li_44 != 0 || li_48 != 0) {

for (int l_pos_56 = 0; l_pos_56 < OrdersTotal(); l_pos_56++) {

if (OrderSelect(l_pos_56, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) lia_52[l_pos_56] = OrderTicket();

if (OrderSelect(lia_52[l_pos_56], SELECT_BY_TICKET) == TRUE) {

if (OrderType() == OP_BUYSTOP) OrderDelete(lia_52[l_pos_56]);

if (OrderType() == OP_SELLSTOP) OrderDelete(lia_52[l_pos_56]);

if (OrderType() == OP_BUY) {

SendMail("MT4 Mail Alert", "Buy Position Hold" + Symbol() + " Lots=" + OrderLots());

g_ord_takeprofit_128 = OrderTakeProfit();

}

}

}

return (0);

}

if (li_40 < 0 && li_44 != 0 || li_48 != 0) {

for (int l_pos_64 = 0; l_pos_64 < OrdersTotal(); l_pos_64++) {

if (OrderSelect(l_pos_64, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) lia_60[l_pos_64] = OrderTicket();

if (OrderSelect(lia_60[l_pos_64], SELECT_BY_TICKET) == TRUE) {

if (OrderType() == OP_BUYSTOP) OrderDelete(lia_60[l_pos_64]);

if (OrderType() == OP_SELLSTOP) OrderDelete(lia_60[l_pos_64]);

if (OrderType() == OP_SELL) {

SendMail("MT4 Mail Alert", "Sell Position Hold" + Symbol() + " Lots=" + OrderLots());

g_ord_takeprofit_128 = OrderTakeProfit();

}

}

}

return (0);

}

if (li_40 != 0 && li_44 == 0 && li_48 == 0 && Use_Trailstop == TRUE) {

for (int l_pos_72 = 0; l_pos_72 < OrdersTotal(); l_pos_72++) {

if (OrderSelect(l_pos_72, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) lia_68[l_pos_72] = OrderTicket();

if (OrderSelect(lia_68[l_pos_72], SELECT_BY_TICKET) == TRUE) {

if (OrderType() == OP_BUY && Ask - OrderStopLoss() > Trail * Point * gi_136) OrderModify(lia_68[l_pos_72], "", Ask - Trail * Point * gi_136, g_ord_takeprofit_128, 0);

if (OrderType() == OP_SELL && OrderStopLoss() - Bid > Trail * Point * gi_136) OrderModify(lia_68[l_pos_72], "", Bid + Trail * Point * gi_136, g_ord_takeprofit_128, 0);

}

}

return (0);

}

if (li_40 == 0 && li_44 != 0 && li_48 != 0) {

for (int l_pos_80 = 0; l_pos_80 < OrdersTotal(); l_pos_80++) {

if (OrderSelect(l_pos_80, SELECT_BY_POS, MODE_TRADES) == FALSE) break;

if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) lia_76[l_pos_80] = OrderTicket();

if (OrderSelect(lia_76[l_pos_80], SELECT_BY_TICKET) == TRUE) {

if (OrderType() == OP_BUYSTOP) OrderModify(lia_76[l_pos_80], Ask + Trigger * Point * gi_136, Ask + (Trigger - Stoploss) * Point * gi_136, Ask + (Trigger + Take_Profit) * Point * gi_136, 0);

if (OrderType() == OP_SELLSTOP) OrderModify(lia_76[l_pos_80], Bid - Trigger * Point * gi_136, Bid - (Trigger - Stoploss) * Point * gi_136, Bid - (Trigger + Take_Profit) * Point * gi_136, 0);

}

}

return (0);

}

if (li_40 == 0 && li_44 == 0 && li_48 == 0 && Repeatable == TRUE) gi_140 = TRUE;

if (gi_140 == TRUE) {

while (li_44 == 0) {

OrderSend(Symbol(), OP_BUYSTOP, l_lots_32, Ask + Trigger * Point * gi_136, Slippage * Point * gi_136, Ask + (Trigger - Stoploss) * Point * gi_136, Ask + (Trigger +

Take_Profit) * Point * gi_136, "", MAGIC, 0);

li_44 = CalculateBuyStopOrders();

Comment("LOTS=", l_lots_32, " ", "Position(+1=Buy -1=Sell)=", li_40,

"\n", "Spread=", Ask - Bid,

"\n", "Min_lot=", l_minlot_4,

"\n", "Max_lot=", l_maxlot_12,

"\n", "AccountCompany=", AccountCompany(),

"\n", "AccountCurrency=", AccountCurrency(),

"\n",

"\n", "POWERED BY albirex7");

}

while (li_48 == 0) {

OrderSend(Symbol(), OP_SELLSTOP, l_lots_32, Bid - Trigger * Point * gi_136, Slippage * Point * gi_136, Bid - (Trigger - Stoploss) * Point * gi_136, Bid - (Trigger +

Take_Profit) * Point * gi_136, "", MAGIC, 0);

li_48 = CalculateSellStopOrders();

Comment("LOTS=", l_lots_32, " ", "Position(+1=Buy -1=Sell)=", li_40,

"\n", "Spread=", Ask - Bid,

"\n", "Min_lot=", l_minlot_4,

"\n", "Max_lot=", l_maxlot_12,

"\n", "AccountCompany=", AccountCompany(),

"\n", "AccountCurrency=", AccountCurrency(),

"\n",

"\n", "POWERED BY albirex7");

}

gi_140 = FALSE;

SendMail("MT4 Mail Alert", "No Position " + Symbol() + " AccountBalance=" + DoubleToStr(AccountBalance(), 2) + AccountCurrency() + " Lots=" + DoubleToStr(l_lots_32, 2));

}

return (0);

}

Link to comment
Share on other sites

Re: (Req) News Trading EA need to remove limitation demo only

 

Thank you APopovA for such quick response. Trully appreciated. :shand:

But please forgive me being newbie, when i try to save and compile it, there's an error saying "un balance parentheses". Could u help? Thank you in advance

Link to comment
Share on other sites

  • 1 year later...
Thank you APopovA for such quick response. Trully appreciated. :shand:

But please forgive me being newbie, when i try to save and compile it, there's an error saying "un balance parentheses". Could u help? Thank you in advance

 

can some friend here look into the error issue and make it compile without error?

 

the one with mentioned error is also not attaching!

Edited by halcyonn
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...