Maximize the number of intraday trades to 3 trades on one day
Forums › ProRealTime English forum › ProOrder support › Maximize the number of intraday trades to 3 trades on one day
- This topic has 6 replies, 4 voices, and was last updated 3 years ago by Jan.
Tagged: one trade daily, otd
-
-
08/25/2017 at 11:30 AM #44617
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:
12345678if intradaybarindex=0 thencount=0endifif (onmarket and barindex=tradeindex) or(barindex=tradeindex and barindex=tradeindex(2)) thencount=count+1endifcountcondition=count<3You have to add countcondition to your buy and sell conditions.
08/25/2017 at 10:29 PM #4465304/29/2018 at 12:15 PM #69368Dear 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
12/28/2020 at 11:15 PM #155493I 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)
Dummy trade algo to limit daily trades123456789101112131415161718192021DEFPARAM cumulateOrders = false // Cumulating positions deactivatedonce N = 1 // nr of contractsOTD = (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 dayif OTD and OpeningTT and not onmarket then //and not onmarket not neededbuy N shares AT marketendif//close positionif onmarket and barindex - tradeindex =2 thensell at marketendif//graph IntradayBarindex//Graph TradeIndex //priceexit//graph barindex01/01/2021 at 12:52 PM #155852About 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.
01/01/2021 at 4:14 PM #155859Thanks 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?)
01/01/2021 at 6:29 PM #155872Goodevening 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.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on