Jump to content

muruku

Members
  • Posts

    183
  • Joined

  • Last visited

Posts posted by muruku

  1. buystop & sellstop in int CloseAllTrades() is nothing in usage. LOL...

    The question in raised had been resolved, pls go back to previous page, read thru & realize them to your code.

     

    Hi muruku, I saw there is a buystop, sellstop in coding, does it works?. What is the function of his pending order in coding. Thanks. It seem when all the total floating profit reach MinProfit = 1.5 or 1.5 t/p reach it wont close all the position including the pending order. I'm testing the code by Azam.
  2. i see your problem that i had before..

    just tweak this logic will make the world happy, so you had to be creative & analytical to know what the problem you had, what resources you had to solve it

     

    if (Pips >= MinProfit){

    while(MyOrdersTotal(Magic) != 0) {

    CloseAllTrades(0,Magic);

    DeletePendingOrders(Magic);

    }

    }

     

     

     

    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?

  3. Global variable for below ... these are fx server time

    int EntryHourFrom = 1; // 5am

    int EntryHourTo = 13; // 6pm still can trade

    int ExitHour = 14; // Stop trade

     

    if(!TelagaEmas && !IsTradeTime()) { DeletePendingOrders(Magic); return (0);}

     

    The sub.

    bool IsTradeTime()

    {

    bool Result=false;

    if((EntryHourFrom<=EntryHourTo && Hour()>=EntryHourFrom && Hour()<=EntryHourTo) ||

    (EntryHourFrom>EntryHourTo && (Hour()>=EntryHourFrom || Hour()<=EntryHourTo)))

    {

    Result=true;

    if(Hour()>=ExitHour)

    if((EntryHourFrom<=EntryHourTo && ExitHour>=EntryHourFrom) ||

    (EntryHourFrom>EntryHourTo && ExitHour>=EntryHourFrom) ||

    (EntryHourFrom>EntryHourTo && ExitHour<=EntryHourTo))

    Result=false;

    }

    return(Result);

    }

     

     

     

     

     

     

    Discard this logic below

     

     

    Anyone, please explain me how the EA run with 2 this function

    "string CableRunNOTtoTradesTime1 =

    string CableRunNOTtoTradesTime2 = " ?

     

    Thanks alot

  4. eggzactly,

    i need a pcs of logic to delete duplication pending orders (entry with same pending buy/sell price) if misfired by EA or broker server turned up to be hair-wired a bit...

     

    I placed a logic to prevent this to be happened as below, but i need a backup logic to wipe up unwanted AFTER if the mentioned duplicated entries HAD happened.

     

    if ((gd_124 - Bid <= 5.0 * Point) && (LastSellPrice != gd_124)) { NewOrder(OP_SELLLIMIT, g_ord_lots_108 + IncLot,NextSLStep,0,0); LastSellPrice = gd_124;}

    if ((Ask - gd_132 <= 5.0 * Point) && (LastBuyPrice != gd_132)) { NewOrder(OP_BUYLIMIT, g_ord_lots_116 + IncLot,NextBLStep,0,0); LastBuyPrice = gd_132;}

  5. that meant your broker never allow you not to set tp & sl ...

    do your own coding pls.

     

    Thank you Muruku... i have got this error 2010.09.22 17:02:21 '2006005': order sell limit 0.10 GBPUSD opening at 1.56702 sl: 0.00000 tp: 0.00000 failed [invalid S/L or T/P]

     

    2010.09.22 16:46:35 '2006005': order sell limit 0.10 GBPUSD opening at 1.56805 sl: 0.00000 tp: 0.00000 failed [invalid S/L or T/P]

     

     

    what can i do to solve it ?

     

    and can you please if you have the newest version with 5digits broker can you share ?

    Thank you

  6. dun be greedy. If i were you, i will turn on max 2 instances during NY-Asian session with 0.1 lots..

    The rest of 24 hrs run, 1 instance only to protect the $

    i would suggest maintain the same codes for all the instances except each will run with diff magic (change this number everytime before you enter the trade, who knows your broker is nasty one).. also keep your eye open for kind of bugs found like ..

    - if Instance A & B open trades almost same time, when their respective MinProfit hit, are ALL of them close up happily with at least greater & equal to MinProfit.. ?, you may want to insert the ordercomment so that visible which to which instances are managing its trades.

    - Will Instance A interfere B in its opened trades ?

    - We shouldn't expect duplicate entries of buy/sell limit by each instance .. you need to fix its logic to ensure this is not happened.. i 'm still studying if there's a logic to "watchdog" if duplication of pending orders happened, how to delete either one.

     

    WOW.. too many wording for today. Cheers !

    Hopefully your guys enjoy them !

  7. These are the 3 ZONES/bands.

    When ATR_pips for current bar, (0) & previous 3 & 4 concurrently fall under either these ZONEs. The trade should trigger (MySignal = 1). R u crystal clear ??

     

    double ATRUpLimit1 = 13.0;

    double ATRDnLimit1 = 7.0;

     

    double ATRUpLimit2 = 21.0;

    double ATRDnLimit2 = 16.0;

     

    double ATRUpLimit3 = 26.0;

    double ATRDnLimit3 = 24.0;

     

     

     

     

     

     

     

     

    Hi muruku,

    thanks again for your job and help.

    Sorry for this question but I need to be sure : the code above means your EA is using 2 ATRPips period settings (3 and 4) together (in the same time) ? And if the currency pair lays inside one of the 3 bands (ATRUpLimit1 = 3.0;ATRDnLimit1 = 7.0;ATRUpLimit2 = 21.0;ATRDnLimit2 = 16.0;ATRUpLimit3 =26.0;ATRDnLimit3 = 24.0), at least for one of the above ATRPips settings, it triggers(enter) the trade ?

    I plotted the two ATRPips but I've seen they never reached (in the last few months) the values of the first band (from 3 to 7) . Probably I didn't got your point !

    Please explain.

  8. Zone C in actual rarely happens.. the theory behind slicing to each zone is ensure ATR_pips lines is FLATTEN & fall within any of these zones indicates market back to ranging phase again & where our bot come to the play...

     

    Look's like you able to cope up with this ATM machine ... what an amazing !

     

     

     

    hi muruku,

     

    i`m still using the Zone A & zone B coding on my cent live account ....

     

     

     

    but maybe now i`ll try your new setting ..... :D

  9. ATR_Pips.ex4 can be found in www.

    we no need this indicator to attach to any chart... as the robot will able to read this indicator's reading via icustom statement.

     

     

     

    Hi, thank you for sharing but when i tried to test it, it showed me this message

    2010.09.22 15:38:25 Cannot open file 'C:\Program Files\FXDD Malta - MetaTrader 4\experts\indicators\ATR_Pips.ex4' on the GBPUSD,M15

     

    although i am using i on the one hour and also i am 5digits.

    i even tried to look for this indicator couldn't find it.

    can you please help me?

    Regards,

  10. Dear fancy, take note the solid rock code I just scripted when inspiration came today.. The while (wild) loop force below clean up all open trades & pending orders when the MinProfit is hit..

    happy coding...

     

    double Pips = TotalProfit(Magic);

    if (Pips >= MinProfit){

    while(MyOrdersTotal(Magic) != 0){

    CloseAllTrades(1, Magic);

    CloseAllTrades(2, Magic);

    DeletePendingOrders(Magic);

    }

  11. too many fancy of C@bleR** here ..

    Here's the ATR pips logic i have...

     

     

    Global variables

    double ATRPeriod1 = 3.0;

    double ATRPeriod2 = 4.0;

     

    double ATRUpLimit1 = 13.0;

    double ATRDnLimit1 = 7.0;

     

    double ATRUpLimit2 = 21.0;

    double ATRDnLimit2 = 16.0;

     

    double ATRUpLimit3 = 26.0;

    double ATRDnLimit3 = 24.0;

     

    ..

    ..

     

    RefreshRates();

     

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

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

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

     

    int MySignal = 0;

     

    if (ATRPrePips1 >= ATRDnLimit1 && ATRPrePips1 <= ATRUpLimit1

    && ATRPrePips2 >= ATRDnLimit1 && ATRPrePips2 <= ATRUpLimit1

    && ATRPips >= ATRDnLimit1 && ATRPips <= ATRUpLimit1

    ) MySignal =1;

     

     

    if (ATRPrePips1 >= ATRDnLimit2 && ATRPrePips1 <= ATRUpLimit2

    && ATRPrePips2 >= ATRDnLimit2 && ATRPrePips2 <= ATRUpLimit2

    && ATRPips >= ATRDnLimit2 && ATRPips <= ATRUpLimit2

    /*|| HowTight >= HowTightDnLimit && HowTight <= HowTightUpLimit*/) MySignal =1;

     

     

    if (ATRPrePips1 >= ATRDnLimit3 && ATRPrePips1 <= ATRUpLimit3

    && ATRPrePips2 >= ATRDnLimit3 && ATRPrePips2 <= ATRUpLimit3

    && ATRPips >= ATRDnLimit3 && ATRPips <= ATRUpLimit3

    ) MySignal =1;

     

    MySignal = 1 ==> enter the trade !

  12. 1. ATR Pips Zone A and Zone B

    - Tune according to your observation & let me know too the BEST setting you had !

    double ATRUpLimit1 = 13.0; // zone A

    double ATRDnLimit1 = 9.0; //

    double ATRPeriod1 = 3.0;

     

    double ATRUpLimit2 = 23.0; // zone B

    double ATRDnLimit2 = 18.0; //

    double ATRPeriod2 = 6.0;

     

     

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

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

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

     

    int MySignal = 0;

     

    if (ATRPrePips1 >= ATRDnLimit1 && ATRPrePips1 <= ATRUpLimit1

    && ATRPrePips2 >= ATRDnLimit1 && ATRPrePips2 <= ATRUpLimit1

    && ATRPips >= ATRDnLimit1 && ATRPips <= ATRUpLimit1) MySignal =1;

     

     

    if (ATRPrePips1 >= ATRDnLimit2 && ATRPrePips1 <= ATRUpLimit2

    && ATRPrePips2 >= ATRDnLimit2 && ATRPrePips2 <= ATRUpLimit2

    && ATRPips >= ATRDnLimit2 && ATRPips <= ATRUpLimit2) MySignal =1;

     

     

    2. TotalProfit(magic)

    -- sometime TotalProfit() flip too fast, (that's why i declare the variable "Pips" to hold it.. so you may want to increase the MinProfit higher. said > 17

     

    double Pips = TotalProfit(Magic);

    if (Pips >= MinProfit){ .. Take your profit }

     

     

    double TotalProfit(int ai_magic)

    {

    int total=OrdersTotal();

    double totalPips = 0.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:

    RefreshRates();

    totalPips += MathRound((MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT));

    break;

     

    case OP_SELL:

    RefreshRates();

    totalPips += MathRound((OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))/MarketInfo(OrderSymbol(),MODE_POINT));

    break;

    }

    }

    }

    return(totalPips);

    }

     

    3. NoTradeTimes

    - Just update today, this one is workable

    string CableRunNOTtoTradesTime1 = "15:00"; <-- example of time in string format

    string CableRunNOTtoTradesTime2 = "19:00"; <-- after all this is broker server time.

    ..you need to let the EA to sleep at NY 8pm -- 12.30am to avoid news

    ..

    if (IsNotTradeTime(CableRunNOTtoTradesTime1, CableRunNOTtoTradesTime2)) { DeletePendingOrders(Magic); return (0);}

    ..

    ..

    bool IsNotTradeTime(string StartHour, string EndHour ) {

    int TimeString1;

    int TimeString2;

    int CurrentTime = TimeCurrent();

    TimeString1 = StrToTime(StartHour);

    TimeString2 = StrToTime(EndHour);

    if (TimeString1 < TimeString2 && CurrentTime < TimeString1 || CurrentTime >= TimeString2) return (FALSE);

    if (TimeString1 > TimeString2 && (CurrentTime < TimeString1 && CurrentTime >= TimeString2)) return (FALSE);

    return (TRUE);

    }

     

    4. dynamic magic number

    -- encourage not to change magic # like logic below ..where ppl like to do at almost beginning of Start()..

    the reason is let say, you turn on this EA 24hrs & still managing multiple open trades until midnight & when roll over to next day, whenever these trades aggregately turn up to be > + 15 pips, since the magic# changed compared to previous day..this EA will lose control to the open pos.. & you make yourself trouble then.. so you figure out what should be the good way ok ?

    if (DayOfWeek() == 1) Magic = 431672;

    if (DayOfWeek() == 2) Magic = 145280;

     

    5. False Keystroke (for bad broker)

    -- this is good skill to master on.. i mentioned in previous thread, once your trading machine on lock or VPS.. this advanced feature will not work.

    In fact, this EA need to open 2 buy/sell limit concurrently.. how can we emulate 2 sets of key stroke at a time ?

     

     

     

     

     

     

    dear muruku,

     

    thanks for the idea and nice coding technique :D.

     

    ok. you dont want to share your latest EA than its ok for me ... hehehe... but can you tell me what code do put in your latest ea ?

     

    from the previous post, its like your already put :-

     

    1. ATR Pips Zone A and Zone B

    2. TotalProfit(magic)

    3. NoTradeTimes

    4. dynamic magic number

    5. False Keystroke (for bad broker)

     

    So, hope you can clarify a bit ... thanks

×
×
  • Create New...