Earn up to
$50000
for inviting friends
to get StartUp Bonus
from InstaForex
No investments required!
GET BONUS
55%
from InstaForex
on every deposit
Reply to thread
Results 1 to 1 of 1

Thread: Learning to create an expert advisor, part 11

  1. #1 You can automatically minimize the read posts in your account in the 'Forum Settings'
    Will work for pips
    I am:
    ----
     
    Somia2020 is on a distinguished road Somia2020's Avatar
    Join Date
    Oct 2020
    Posts
    93
    Accumulated bonus
    68 USD (What is this?)
    Thanks
    0
    Thanked 242 Times in 51 Posts
    SubscribeSubscribe
    Subsribed 0

    Post Learning to create an expert advisor, part 11

    Name: 19-1-2021 8-03-23 PM.png Views: 9 Size: 168.9 KB
    Here are some of the important functions I use a lot in my extras.

    Moreover, I think it will do you good, too.

    These functions are easy to use and very understandable, and all depend on one entry is the distinctive magic number of deals ...

    The first job:

    MyRealOrdersTotal

    You return the number of real trades opened by Expert whether they are buying or selling:

    PHP code:


    Code:
    int MyRealOrdersTotal(int Magic)
    {
      int c=0;
      int total  = OrdersTotal();
    
      for (int cnt = 0 ; cnt < total ; cnt++)
      {
        OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
        if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUY || OrderType()==OP_SELL))
        {
          c++;
        }
      }
      return(c);
    }
    Second job

    MyPendingOrdersTotal

    You return the number of pending trades by Expert whether they are sold or bought by both Stop and limit.

    PHP code:


    Code:
    int MyPendingOrdersTotal(int Magic)
    {
      int c=0;
      int total  = OrdersTotal();
     
      for (int cnt = 0 ; cnt < total ; cnt++)
      {
        OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
        if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP))
        {
          c++;
        }
      }
      return(c);
    }

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  2. The Following User Says Thank You to Somia2020 For This Useful Post:

    ghada1996 (23-01-2021)

Reply to thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts