Jump to content

Cable Run from Profitable FX


Recommended Posts

  • Replies 921
  • Created
  • Last Reply

Top Posters In This Topic

Can i know how to set it? is that open the cable run2.mq4 and change inside the code?but i cannot find this code (extern int ATR_Period) thanks for help

 

Muruku:

 

Nice work.

Cleaned up your code a bit and added some external variables:

 

extern int ATR_Period      = 14;
extern int ATRPipsLimit    = 17;  // ATR_Pips need to be smaller than this limit to grant the trade

So now we can play with these two variables a bit easier to determine correct settings.

 

Download here:

 

Be kind and say Thanks if you like..!

 

Cheers, San.

Edited by San4x
Thanks for the kudos...much appreciated!
Link to comment
Share on other sites

I've got the " Error: 130 Function: New Order "

 

Ordersend Error 130 denotes an invalid stop on the order. Stop (SL) seems too close to price for order to be accepted by broker.

 

Here is more info and how to check/fix it:

 

Cheers, San
Thanks for the kudos...much appreciated!
Link to comment
Share on other sites

Ordersend Error 130 denotes an invalid stop on the order. Stop (SL) seems too close to price for order to be accepted by broker.

 

Cheers, San

 

Thanks San

 

You're right, i've just run it on a Masterforex Demo without a problem. But my real account is in FxPro and give me that error.

 

Can you help me to insert those variables into the code?

 

In advance thank you very much.

 

luigi

Link to comment
Share on other sites

as far as i know, when an EA had external indicators attached as our case below(icustom).. the EA would never backtestable... so please dun waste your time... go to do something useful..

 

double ATRPips =iCustom(NULL,PERIOD_M15,"ATR_Pips",0,0);

i glanced thru above threads, guess somebody still not well verse how to do things correctly..

below external variable is set in ATR_Pips.mq4 itself.

 

//---input variables

extern int ATR_Period=13;

 

& in the EA,

double ATRLimit = 12.0; // good at 12 at 11-sep!!

..

..

..

double ATRPips =iCustom(NULL,PERIOD_M15,"ATR_Pips",0,0);

...

..

 

if( ATRPips <= ATRLimit && MyOrdersTotal(Magic) == 0) {

..

Link to comment
Share on other sites

as far as i know, when an EA had external indicators attached as our case below(icustom).. the EA would never backtestable... so please dun waste your time... go to do something useful..

 

double ATRPips =iCustom(NULL,PERIOD_M15,"ATR_Pips",0,0);

i glanced thru above threads, guess somebody still not well verse how to do things correctly..

below external variable is set in ATR_Pips.mq4 itself.

 

//---input variables

extern int ATR_Period=13;

 

& in the EA,

double ATRLimit = 12.0; // good at 12 at 11-sep!!

..

..

..

double ATRPips =iCustom(NULL,PERIOD_M15,"ATR_Pips",0,0);

...

..

 

if( ATRPips <= ATRLimit && MyOrdersTotal(Magic) == 0) {

..

 

I guess you're talking about my mod. What's wrong?

 

Cheers, San.

Thanks for the kudos...much appreciated!
Link to comment
Share on other sites

 

& in the EA,

double ATRLimit = 12.0; // good at 12 at 11-sep!!

..

..

..

double ATRPips =iCustom(NULL,PERIOD_M15,"ATR_Pips",0,0);

...

..

 

if( ATRPips <= ATRLimit && MyOrdersTotal(Magic) == 0) {

..

 

I could not find this line in the EA:

 

double ATRLimit = 12.0; // good at 12 at 11-sep!!

 

If I should add it manually, where should I put that line?

 

Thx

Link to comment
Share on other sites

Hi all,sorry for asking because i not good in English. So i just want make it clear how to run this EA.

1) Attach the EA by muruku at 1 hour chat G/U.

2) Attach the ATR_pips.ex4 indicator from indicator list. So can change the ATR_pip value. Recommended value=17 from friend here.

3) If want to change the start/end trading time for this EA, is that need to change inside the code for the EA? hope friend here can modify the time setting just at the EA setting, so no need change the code inside:)

4) If i miss anything, hope friend here can help fill up.thanks a lot

Link to comment
Share on other sites

i suggest all of us to study ATR_Pips.mq4 based on which optimized setting should be to decide when the market is abt to RANGING/Consolidation period to let this EA to enter/initialize the first trade.

Hardcode of Trading time control may gain lesser profit...

//---input variables

extern int ATR_Period=5;

What do you think ? currently i set to 5 for above, & for EA, i set to be <= 9 to open the trades. You should ez spot whenever the incoming news, ATR_Pips.mq4 should be smart enough to filter / prevent EA to turn on the trade...

I may not be right/wrong, your folks be self-studied & responsible of your own trades..

dun simply hop onto the bandwagons :)

Link to comment
Share on other sites

i got 105 pips today, after close all orders manually... it was 159 pips before NY session... :)

muruku.. i have no idea why the ea still open orders after 09:00 when i set CableRunEndTime at 09:00:

 

string CableRunStartTime = "0:30"; // 1:00=5.00am myfxbook 7am onwards is good !!!!

string CableRunEndTime = "9:00"; // 9:00=1.00pm

 

is the time setting correct?

Link to comment
Share on other sites

i got 105 pips today, after close all orders manually... it was 159 pips before NY session... :)

muruku.. i have no idea why the ea still open orders after 09:00 when i set CableRunEndTime at 09:00:

 

string CableRunStartTime = "0:30"; // 1:00=5.00am myfxbook 7am onwards is good !!!!

string CableRunEndTime = "9:00"; // 9:00=1.00pm

 

is the time setting correct?

 

Muruku:

Ohh.. Is it because I set parameter "TelagaEmas" to true? Should I set it to false if I want to trade in a specific time?

Link to comment
Share on other sites

Celvereto, you r right, when "telagaEmas" is true, the EA works 24 hrs. (tried to hide as many parameters as we can, although they are far more aware if we r running manual/EA)..

The new logic below will let you run 2 set of C*b**Run in same MT platform, discard the usage of GlobalVariableSet that only limit the play of the only 1 C*b**Run .

just clone out another set of EA & having them to run with diff magic #... & you will have more pips !

Would like to precaution any fancies abt C*b**Run, better write a logic on SL too.

 

if (TotalProfit(Magic) > MinProfit){

CloseAllTrades(1, Magic);

CloseAllTrades(2, Magic);

//GlobalVariableSet("OldBalance", 0);

}

 

int TotalProfit(int ai_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()== ai_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);

}

Link to comment
Share on other sites

Muruku:

Ohh.. Is it because I set parameter "TelagaEmas" to true? Should I set it to false if I want to trade in a specific time?

 

why your open orders need to close manually ? below codes are excellent/brutal force way to make sure all open orders are swept cleanly after profit had made.

 

int CloseAllTrades(int ai_0, int ai_magic) {

int l_count_8;

int l_error_12;

int li_16 = 4;

int li_20 = 5;

int l_ord_total_23 = OrdersTotal();

for (int l_pos_36 = l_ord_total_23 - 1; l_pos_36 >= 0; l_pos_36--) {

if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) {

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

l_count_8 = 0;

while (l_count_8 < li_16) {

switch (OrderType()) {

case OP_BUY:

if (ai_0 == 0 || ai_0 == 2) {

RefreshRates();

OrderClose(OrderTicket(), OrderLots(), Bid, 0, CLR_NONE /*White*/);

}

break;

case OP_SELL:

if (ai_0 == 0 || ai_0 == 1) {

RefreshRates();

OrderClose(OrderTicket(), OrderLots(), Ask, 0, CLR_NONE/*White*/);

}

break;

case OP_BUYLIMIT:

case OP_BUYSTOP:

if (ai_0 == 0 || ai_0 == 2) OrderDelete(OrderTicket());

break;

case OP_SELLLIMIT:

case OP_SELLSTOP:

if (ai_0 == 0 || ai_0 == 1) OrderDelete(OrderTicket());

}

l_error_12 = GetLastError();

if (l_error_12 == 0/* NO_ERROR */) l_count_8 = li_16;

else {

l_count_8++;

if (l_error_12 == 138/* REQUOTE */ || l_error_12 == 129/* INVALID_PRICE */) continue;

if (l_error_12 == 146/* TRADE_CONTEXT_BUSY */) {

MySleep(li_20);

li_16 = 10;

}

}

}

}

} else {

//Print("CloseAllTrades Error when order select ", GetLastError());

SendMail("LombongBerlian ada Error tutup "+ Period(), WindowExpertName()+" "+GetLastError());

break;

}

}

return (0);

}

Link to comment
Share on other sites

i shouldn't invest time in mq4 code as i 'm just parttimer like others working man .. lol, i dun know .. missing logic just attach..

 

int MySleep(int ai_0) {

int l_datetime_4;

bool li_8 = FALSE;

int l_datetime_12 = TimeLocal();

while (!li_8) {

l_datetime_4 = TimeLocal();

if (l_datetime_4 >= l_datetime_12 + ai_0) li_8 = TRUE;

else Sleep(500);

}

return (0);

}

Link to comment
Share on other sites

Celvereto, you r right, when "telagaEmas" is true, the EA works 24 hrs. (tried to hide as many parameters as we can, although they are far more aware if we r running manual/EA)..

The new logic below will let you run 2 set of C*b**Run in same MT platform, discard the usage of GlobalVariableSet that only limit the play of the only 1 C*b**Run .

just clone out another set of EA & having them to run with diff magic #... & you will have more pips !

Would like to precaution any fancies abt C*b**Run, better write a logic on SL too.

 

if (TotalProfit(Magic) > MinProfit){

CloseAllTrades(1, Magic);

CloseAllTrades(2, Magic);

//GlobalVariableSet("OldBalance", 0);

}

 

int TotalProfit(int ai_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()== ai_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);

}

 

Thank U so much Bro,

I'd love to try how those new logic will work.. 2 Diff set of C*b**Run in one account? I think it's really worth to try..

But honestly I still don't know how to put those logic in the EA :) should I just add it or edit any existing logic? I'm sorry, I still blind about coding mq4.. still new at this..

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...