Maximize the number of intraday trades to 3 trades on one day

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #44617 quote
    Henry
    Participant
    Average

    A request that was addressed to ProRealTime:

    I am looking for the code to maximize the number of intraday trades of an automatic intraday system to 3 trades on one day.

    Suggestion for an anwser:

     

    if intradaybarindex=0 then
    count=0
    endif
    if (onmarket and barindex=tradeindex) or(barindex=tradeindex and barindex=tradeindex(2)) then
    count=count+1
    endif
    
    countcondition=count<3

    You have to add countcondition to your buy and sell conditions.

    #44653 quote
    Despair
    Blocked
    Master

    Does this work?

    #69368 quote
    Jan
    Participant
    Veteran

    Dear Henry,

     

    I want to reduce my trades to one per day, then I searched on “Maximize the number of intraday trades ” and came to your request. I was not aware of IntradayBarIndex command possibility.

    If you want to limit your trades to one per day,  the following added condition will do:    IntradayBarIndex < (Barindex – TradeIndex(1))

    Consequently if you wan tot limit your trades to three per day,  the added condition  — IntradayBarIndex < (Barindex – TradeIndex(3)) —  should work.  Barindex  – TradeIndex(3) counts the bars between the current bar and the third previous trade (close trade)

    Hope it helps

    Do you know you can search the whole Prorealcode.com website by typing a requested topic at Search , when clicking on your AccountID, right top on the screen, see also attached Word printscreen.

     

    Kind regards,

    Jan

    Search-the-ProRealCode-website.docx
    #155493 quote
    Jan
    Participant
    Veteran

    I found a problem in version 11 with limiting trades per day:

    in back testing it works fine, but with activating Automated Trading at PRT version 11, it does not work : no error codes given, the code runs in automated trading, but it does not trade ??

    I have used the code often, and it used to work fine, could anyone give me feedback what is going wrong ? See the line below and the dummy code below in the box, what I tested.

    OTD = (Barindex – TradeIndex(1) > IntradayBarIndex) // IntradayBarIndex < (Barindex – TradeIndex(1)) limits the (opening) trades till 1 per day (OTD One Trade per Day)

    DEFPARAM cumulateOrders = false // Cumulating positions deactivated
    
    once N = 1  // nr of contracts
    
    OTD = (Barindex - TradeIndex(1) > IntradayBarIndex)  // IntradayBarIndex < (Barindex - TradeIndex(1)) limits the (opening) trades till  1 per day (OTD One Trade per Day)
    
    OpeningTT = Time >= 73000 and Time <= 231500 // trading times
    
    
    // open buy limited to 2 roundturns per day
    if OTD and OpeningTT and not onmarket then //and not onmarket not needed
    buy N shares AT market
    endif
    //close position
    if onmarket and barindex - tradeindex =2 then
    sell at market
    endif
    
    //graph IntradayBarindex
    //Graph TradeIndex //priceexit
    //graph barindex
    
    #155852 quote
    Jan
    Participant
    Veteran

    About my previous post above: I found that there is no error, so no problem.

    Make sure a strategy with limited trades per day, as coded OTD = (Barindex TradeIndex(1) > IntradayBarIndex) starts running the previous day, than it works fine !

    Explanation:

    OTD = (Barindex TradeIndex(1) > IntradayBarIndex)  :   

    When starting running the strategy,  TradeIndex is always zero, as not trade made yet !  During the first day after the strategy has been started,  Barindex  equals IntradayBarindex and, as TradeIndex is initially zero,  the condition Barindex TradeIndex(1) > IntradayBarIndex is never true.  IntradayBarindex resets every day, it counts the bars during the day.

    The next day of running the strategy, Barindex is greater then IntradayBarindex, so the condition become true, and the limitation of number of trades works fine.

    #155859 quote
    nonetheless
    Participant
    Master

    Thanks for that clarification Jan. I have a few strategies that use your OTD code (in conjunction with your crossing averages), but they’re recently re-worked for v11 and haven’t taken any trades yet.

    But do you mean that OTD will work on the second day after activation, or the second day after it takes a trade? (ie, the first day that it trades it will potentially make more than one?)

    #155872 quote
    Jan
    Participant
    Veteran

    Goodevening nonetheless,

     

    a healthy and prosperous New Year 2021 !

    To answer your question:

    OTD will work the second day after activation.

    At the first day after activation Barindex and IntradayBarindex are always the same,  and the  (Barindex  TradeIndex(1> IntradayBarIndex)  never becomes true.  This changes as BarIndex continues on the second day, while IntradayBarIndex resets itself.

    In the simulation results, you do not see this (that’s why I could not understand it was not working after activation), as default 1000 bars are loaded. If you enter at the end of the dummy code “Graph Barindex” and “Graph IntradayBarIndex” you can see the values of the two.

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

Maximize the number of intraday trades to 3 trades on one day


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Henry @henry Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by Jan
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/25/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...