I have developed a trading strategy and backtested the same using ProRealtrade. I used OTD = Barindex - TradeIndex(1) > IntradayBarIndex to limit the order to one per day. Now i want to see how the results are if i increase number of trades per day to two.
I searched in the forum below and found below code should be used to limit orders per day to two. However, i am struggling to understand how this code works and it’s not currently delivering my need.
( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) )
Please can i get some help in limiting number of order per day to 2 and this can be configurable..
There you go:
ONCE MaxTrades = 2
ONCE Tally = 0
//
// reset the TALLY each new day
//
IF IntraDayBarIndex = 0 THEN
Tally = 0
ENDIF
//
// enter a trade when conditions are met AND the trade to be opened doesn't exceed MaxTrades
IF MyLongConditions AND (Tally < MaxTrades) THEN
BUY 1 CONTRACT AT MARKET
Tally = Tally + 1
ELSIF MyShortConditions AND (Tally < MaxTrades) THEN
SELLSHORT 1 CONTRACT AT MARKET
Tally = Tally + 1
ENDIF
SET STOP pLOSS 100
SET TARGET pPROFIT 200
Thats brilliant. Thank you.