Results 1 to 5 of 5
 0 Attachment(s)    

Thread: Resume Trading after X Days after MaxLots?

  1. #1

    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

    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.

  3. #3

    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

    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 09:08.

  5. #5

    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

Similar Threads

  1. Manual trading forex success and every-days
    By ForexAndy in forum Commercial manual systems
    Replies: 0
    Last Post: 03-22-2015, 13:20
  2. My more than 100% profit in 9 days
    By timidave in forum Manual systems statements
    Replies: 11
    Last Post: 12-15-2012, 22:19
  3. MinLots and MaxLots
    By funyoo in forum MQL programming
    Replies: 0
    Last Post: 04-15-2009, 11:29
  4. Trading to certain days and hours
    By HiwayNZ in forum MQL programming
    Replies: 1
    Last Post: 02-08-2009, 18:08

Tags for this Thread

how to, pips, time, trading

Posting Permissions

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