End orders but not active trade

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #223918 quote
    slumpy man
    Participant
    New

    Hello everyone, I’m very new to all of this so this is probably a basic question for you.

    I want my pending orders to stop at a certain time but my code also stops any active trades. So far I have this:

    DEFPARAM FLATBEFORE=073000

    DEFPARAM FLATAFTER=083000

     

    How do I just let the active trades continue without being stopped?

    #223927 quote
    robertogozzi
    Moderator
    Master

    Pending orders only last one bar. So you don’t need to cancel them. Just stop placing them after the time of your choice. This is valid for intraday timeframes.

    If you are trading a daily timeframe you will need to resort to multiple timeframe, so that you can place pending orders in an intraday timeframe, stopping placing them when needed.

    #223937 quote
    slumpy man
    Participant
    New

    the pending orders do stop but its the active trade I’m concerned about. It gets stopped wherever it is at the DEFPARAM FLATAFTER time. I just want it to continue

    #223959 quote
    Jean FX
    Moderator
    New

    Roberto is right, you just need to remove your flatafter and not to place WO.

    #223963 quote
    PeterSt
    Participant
    Master

    I want my pending orders to stop at a certain time but my code also stops any active trades.

    Possibly you don’t realize that a “pending order” is a functional phenomenon which really is different than “a program code which must stop trading new orders”.
    I think you refer to the latter. In that case, you should try to make something like this :

    If Time >= 073000 and Time <= 083000 then
    
      // Here your code to enter new trades.
    
    endif
    
    // Here your code to exit trades, assumed you want this between 07:30 and 08:30.

    A Pending Order is of the form

    Buy x Contracts at MyPrice Limit   // Needs to be repeated each bar (= call of code).
    //or
    Sell x Contracts at MyPrice Stop   // Ditto.
    
    Buy x Contracts at Market          // This is not a Pending order. It will execute immediately.
    #224099 quote
    slumpy man
    Participant
    New

    Hmm still not working for me. Trades are coming in after 830 with that code still

    #224133 quote
    PeterSt
    Participant
    Master

    Can you show the code of concern ?

    #224226 quote
    slumpy man
    Participant
    New

    I figured it out. I just had to add endtime = 083000 and then add endtime to my orders line

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

End orders but not active trade


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
slumpy man @mikejasz Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by slumpy man
2 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/19/2023
Status: Active
Attachments: No files
Logo Logo
Loading...