+ Reply to Thread
Results 1 to 5 of 5
 0 Attachment(s)    

Thread: Resume Trading after X Days after MaxLots?

  1. #1
    Member sleepypipsCDN's Avatar
    Join Date
    Apr 2009
    Posts
    32

    Default Resume Trading after X Days after MaxLots?

    can anyone spot my problem with getting an EA to resume trading after MaxTrades?

    hourstoresumetrading=48



    Code:
    int resumetrading;
    
    if (ticket > 0) resumetrading = TimeCurrent() + 60.0 * (60.0 * HoursToResumeTrades);

    Code:
    if (UseResumeTrading)
             {
             if (TimeCurrent() >= resumetrading)
                {
                     
                
                   RefreshRates();
                   LastBuyPrice = FindLastBuyPrice();
                   LastSellPrice = FindLastSellPrice();
                   if (LongTrade && LastBuyPrice - Ask >= PipStep * Point) TradeNow = TRUE;
                   if (ShortTrade && Bid - LastSellPrice >= PipStep * Point) TradeNow = TRUE;
                   }
             
                }
    somehow, TradeNow is coming out False
    thanks for anyhelp, even if you have a better idea how to achieve this.

    SP
    "If you took everything I've accomplished in my life, and condensed it down to one day, it'd be decent." -- George Costanza

  2. #2
    Member
    Join Date
    Jan 2009
    Posts
    151

    Default

    Do your open trades have stops and TPs that don't need adjusting?

    If that is the case, why don't you count your open orders and if the order count>=MaxTrades use the Sleep() function to halt the EA?

    The only issue which wasn't clear from your post was if you wanted to resume trading again as soon as one or more of your orders was closed out. If the Sleep() function had suspended execution of the EA, then you wouldn't take any fresh trades until the time was right.
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

  3. #3
    Member sleepypipsCDN's Avatar
    Join Date
    Apr 2009
    Posts
    32

    Default

    Hi Jezzer, yes , stops and TPs do need adjusting.

    No, I wasn't intending it to resume after one or more orders closed out either.

    I just want to stop adding orders until after a certain number of days. After MaxTrades, let it sit with a little gas left in the margin tank, so to speak, and then add the next position X days later, thereby passing on some pipsteps/lotexponents.

    Maybe that Sleep() would do the trick anyway, i'll give it a go, ,thanks.
    "If you took everything I've accomplished in my life, and condensed it down to one day, it'd be decent." -- George Costanza

  4. #4
    Member
    Join Date
    Jan 2009
    Posts
    151

    Default

    The Sleep() function will halt execution of the whole EA, so you will be unable to adjust your stops while the EA is "sleeping".

    Going back to your original code, what does "ticket" refer to? Is it a count of orders or something similar?

    As your code stands, the "resumetrading" integer will be increasing continually all of the time that ticket>0, because TimeCurrent() is itself continually increasing. This means that "resumetrading" will therefore always be greater than TimeCurrent(). This in turn means that your condition in the second block of code:

    Code:
    if (TimeCurrent() >= resumetrading)
                {//
                }
    will never be attained.

    If the condition is never attained, TradeNow will never come true.
    Last edited by jezzer1961; 06-17-2009 at 08:08.
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

  5. #5
    Member sleepypipsCDN's Avatar
    Join Date
    Apr 2009
    Posts
    32

    Thumbs up

    Jezzer, you absolutely nailed that one

    Thanks so much for that. A fresh pair of eyes is what was needed!

    bonehead mistake

    much appreciated again Jezz, good trading to you
    "If you took everything I've accomplished in my life, and condensed it down to one day, it'd be decent." -- George Costanza

+ Reply to Thread

Similar Threads

  1. Comments on trade for 2 days
    By hymera in forum Manual systems demo statements
    Replies: 9
    Last Post: 02-11-2010, 10:07
  2. MinLots and MaxLots
    By funyoo in forum MQL programming
    Replies: 0
    Last Post: 04-15-2009, 10:29
  3. Trading to certain days and hours
    By HiwayNZ in forum MQL programming
    Replies: 1
    Last Post: 02-08-2009, 17:08

Posting Permissions

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