Results 1 to 3 of 3
 1 Attachment(s)    

Thread: Basket Profit/Loss Bug

  1. #1

    Question Basket Profit/Loss Bug

    Hi! I was testing the Basket Profit/Loss function and I found a bug.

    Example:

    Profit=10
    Loss=5

    When one of the those levels is reached the EA doesn't close all the traders, if you know how to correct it, please let me know, above you can check the code that I am using.

    extern bool UseProfitLoss=true;
    extern int BasketProfit=50;
    extern int BasketLoss=100;

    //Basket Profit/Loss
    if(UseProfitLoss)
    {
    CurrentBasket=AccountEquity()-AccountBalance();
    if(CurrentBasket >= BasketProfit || CurrentBasket <= (BasketLoss*(-1)))
    {
    NewOrders=false;
    CloseSellOrders(Magic);
    CloseBuyOrders(Magic);
    return(0);
    }
    }

    Thanks in advance!

  2. #2

    Default

    Without seeing what happens inside the CloseSellOrders() and CloseBuyOrders() functions, it is impossible to see what exactly is wrong.

    You must ensure that these two function close all open orders before passing control back to the originating function. If they return control back before everything is closed, then the close conditions will no longer be met and the EA will have no reason to close any of the remaining orders.

  3. #3

    Smile

    Quote Originally Posted by jezzer1961 View Post
    Without seeing what happens inside the CloseSellOrders() and CloseBuyOrders() functions, it is impossible to see what exactly is wrong.

    You must ensure that these two function close all open orders before passing control back to the originating function. If they return control back before everything is closed, then the close conditions will no longer be met and the EA will have no reason to close any of the remaining orders.
    Thanks for reply and help! I found a very good Basket Profit/Loss code and , I am attaching an "EA" without any signal condition just for the people who need this function can take look at the code.

    Copyrights: I got the code of this "EA" from here and the Basket code here: Multi-purpose trade management ea @ Forex Factory *- I just changed very small things in the code.

    *I don't know if I can post a link from another forum, but if the admin doesn't allow it, please remove it.
    Attached Files Attached Files

Similar Threads

  1. regressive basket profit ea, does it exist?
    By OneandOnly666 in forum Scripts and other tools
    Replies: 0
    Last Post: 07-22-2014, 16:55
  2. Triple ZigZag EA profit basket bug
    By pihurik in forum MQL programming
    Replies: 1
    Last Post: 01-04-2011, 10:44
  3. [Req] Basket Profit Pips Locking
    By Trint in forum Ideas for expert advisors
    Replies: 1
    Last Post: 06-21-2010, 03:14
  4. Add take profit and stop loss
    By funyoo in forum MQL programming
    Replies: 0
    Last Post: 09-23-2008, 11:32

Tags for this Thread

100, how to, magic, profit, signal

Posting Permissions

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