Not logged in

Forums

Replies created

Forum Replies Created

Viewing 14 posts - 1 through 14 (of 14 total)
  • in reply to: 'Market Position is Flat' Doubt #202979 |
    Participant
    20 Posts

    Hi Tomas,

    If you were to scan over all pairs would you just create a custome function and take out the highlighted symbol code (in the previous posts attached picture)?

    My actually question is, is this the most efficient way?

    Kind Regards

    Steve

     

    in reply to: Minute[0] #202117
    Participant
    20 Posts

    Sent via e-mail as throwing an error when I attach it here.

    in reply to: Minute[0] #202116
    Participant
    20 Posts

    I’ve attached my demo here. Thank you.

    in reply to: Minute[0] #202091
    Participant
    20 Posts

    Tomas in short I only want to go into orders between minute 0 and minute 40 within the hour. I need to valuate what is the current minute within the hour.

     

    Thanks

    • This reply was modified 1 month, 2 weeks ago by  Steve Green.
    in reply to: Minute[0] #202089
    Participant
    20 Posts

    Thanks for your response Tomas.

     

    I attached it to the H1 chart. Will this make a difference?

    Can you please make me a little demo.

     

    Kind Regards

    Steve

     

    • This reply was modified 1 month, 2 weeks ago by  Steve Green.
    in reply to: Minute[0] #202051
    Participant
    20 Posts

    Hi,

    In a demo run this morning it also returned 0?

    I only what to go into orders between minute 0 and minute 40 for instance. I need to valuate what is the current minute.

     

    Kind Regards

    Steve

    Participant
    20 Posts

    Hi Tomas,

    Please ignore.

    With further testing it seems to be working correctly.

    Kind Regards

    Steve

    Participant
    20 Posts

    The mails was in my spam folder.

    I’ve sent you a mail.

     

    Thanks

    Participant
    20 Posts

    Hi Tomas,

    Have not received a mail or an alert from this post to my mails? (maybe a problem with your mail server).

    On further analysis this too happens. On both strategies I take partial profits and breakeven with the same ATR formula for example      0.4 * ATR ….

    On analysis it breakevens first then only then it takes partial profits. There is a long lag before partial profits is taken?

     

    Surly this must be done simultaneously?

    Thanks in advance.

    Kind Regards

    Steve

     

    Participant
    20 Posts

    Hi Tomas,

    This was the problem. An undocumented feature and as I assumed the way the data is stored. See link: https://www.mql5.com/en/forum/126192

    From the link an extract below:
    OrdersHistoryTotal()’s name is a bit misleading, cause it also includes balance and credit statements. So this method might be potentially unreliable… A better solution would be to loop on orders in history and count (filtering out balance and credit statements).

     

    FYI, although not officially documented, these are the OrderType() of balance/credit statements when they are selected:

     

    ‘Balance’ statement: OrderType()==6
    ‘Credit’ statement: OrderType()==7

     

    I’ve made changes accordingly and all is working as designed.

     

    Just to let you know.

    Kind Regards
    Steve

    Participant
    20 Posts

    Hi Tomas,

    I’m not to sure where the problem is in the 3 custome functions I’ve coded so I’ve pasted them all below. I suppose it could be in any of the 3.

    In the tester in Mt4 it works fine but when I run on a demo account it adds the account balance in to the total sum.

    The three custome function code is below:

    — I initialize this variable like the below
    lv_NumOrdersToday = GetAllOrdersOpenedToday(0, “false”);

    int GetAllOrdersOpenedToday(int direction, string includePending) {
    string todayTime = TimeToStr( TimeCurrent(), TIME_DATE);
    int tradesOpenedToday = 0;

    for(int i=0;i<OrdersHistoryTotal();i++) {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true) {

    if(direction == 1) {
    if(OrderType() == OP_SELL || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
    // skip short orders
    continue;
    }
    } else if(direction == -1) {
    if(OrderType() == OP_BUY || OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP) {
    // skip long orders
    continue;
    }
    }

    if(includePending == “false”) {
    if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
    // skip pending orders
    continue;
    }
    }

    if(TimeToStr( OrderOpenTime(), TIME_DATE) == todayTime) {
    tradesOpenedToday++;
    }
    }
    }

    for (int cc = OrdersTotal() – 1; cc >= 0; cc–) {
    if (OrderSelect(cc, SELECT_BY_POS)) {

    if(direction == 1) {
    if(OrderType() == OP_SELL || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
    // skip short orders
    continue;
    }
    } else if(direction == -1) {
    if(OrderType() == OP_BUY || OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP) {
    // skip long orders
    continue;
    }
    }

    if(includePending == “false”) {
    if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
    // skip pending orders
    continue;
    }
    }

    if(TimeToStr( OrderOpenTime(), TIME_DATE) == todayTime) {
    tradesOpenedToday++;
    }
    }
    }

    return(tradesOpenedToday);
    }

    — passed into this function is lv_NumOrdersToday from the above function
    double GetAllTotalClosedPLInMoney(int orderMagicNumber, int numberOfLastOrders) {
    double pl = 0;
    int count = 0;

    for(int i=OrdersHistoryTotal(); i>=0; i–) {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true) {
    if(orderMagicNumber == 0 || OrderMagicNumber() == orderMagicNumber) {
    count++;
    pl = pl + OrderProfit();

    if(count >= numberOfLastOrders) break;
    }
    }
    }

    return(pl);
    }

    double GetALLOpenPLInMoney(int orderMagicNumber) {
    double pl = 0;

    for(int cnt = 0; cnt < OrdersTotal(); cnt ++)
    {
    if (!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) continue;
    if(orderMagicNumber == 0 || OrderMagicNumber() == orderMagicNumber) continue;

    pl += OrderProfit();
    }

    return(pl);
    }

    The functionality I’m trying to build is to add the 2 functions ((GetALLOpenPLInMoney(0) + GetAllTotalClosedPLInMoney(0, lv_NumOrdersToday)) results together and see if it is above or below a predetermined capped Profit or Loss daily amount and if so then I suspend trading on all currency pairs.

    Once again when I run in MT4 tester it works fine but when I run on a demo account it includes the account balance into the sum for an unknown reason.

    i.e. 5023 instead of 23 on a 5000 account.

    Thanking you

    Kind Regards
    Steve

    Participant
    20 Posts

    Thanks nolube

    Participant
    20 Posts

    Will we be automatically upgraded?

    Participant
    20 Posts

    nolube thanks for the technical solution, it will help. I assume if you running the same EA over many currency pairs the variable keeps the context of the value per currency pair. i.e. won’t get cross wired…

    I was trying to find out the theory behind this, as in what is regarded as best principles of closing positions partially by other traders, like what ATR value to use and are there costs involved in doing so etc etc

    Thanks in advance

Viewing 14 posts - 1 through 14 (of 14 total)