Only one trade per day.
My auto system trades between 09h00 & 15h00 and can take several trades per day.
I now wish to only take one trade per day, the first one.
How do I code this requirement?
As posted in https://www.prorealcode.com/topic/help-with-limiting-strategy-to-one-trade-per-day/#post-143705, you can use
OTD = Barindex - TradeIndex(1) > IntradayBarIndex
then you can add OTD to your entry conditions, like the example in the link above.
Thank you so much Roberto.
I could hardly believe the speed of response !
OTD worked like a charm.
Spoke too soon.
OTD worked perfectly on back test but when live didnt enter trade when it should have.
I have taken this up with PRT as per norm but no solution as yet. Any suggestions ??
These 2 snippets seem to work as expected (one uses OTD, the other one doesn’t):
DEFPARAM CumulateOrders = False
OTD = Barindex - TradeIndex(1) > IntradayBarIndex
Bulls = summation[3](close >= open) = 3
Bears = summation[3](close <= open) = 3
IF Bulls AND Bears[3] AND Not OnMarket AND OTD THEN
BUY AT MARKET
ENDIF
SET TARGET pPROFIT 6
SET STOP pLOSS 6
DEFPARAM CumulateOrders = False
Bulls = summation[3](close >= open) = 3
Bears = summation[3](close <= open) = 3
IF Bulls AND Bears[3] AND Not OnMarket THEN
BUY AT MARKET
ENDIF
SET TARGET pPROFIT 6
SET STOP pLOSS 6
anyway, I’ll keep testing them next Monday.
JSParticipant
Senior
Hi @897148
Note that the TradeIndex(1) gives both a value when a position is opened and also when a position is closed…
With “If OnMarket and OTD” you know that a position was opened yesterday (or earlier) that is currently still open…
With “If NOT OnMarket and OTD” you know that a position was closed yesterday (or earlier) and that a position can now be opened again…
As Roberto also points out, use the OTD in combination with NOT OnMarket….
If Conditions and NOT OnMarket and OTD then
“Buy or SellShort”
…
My two snippets work correctly, the one using OTD opens only 1 trade per day, while the other one opens tens of trades.
I need to give a very big thankyou to Roberto and JS.
The OTD and Not OnMarket worked perfectly today when I ran live along with the original, multi trade version which took two trades in the allocated time but OTD only one as desired.
I still find it hard to believe how helpful some people are. Restores some much needed faith in mankind .
OTD = Barindex - TradeIndex(1) > IntradayBarIndex
If myConditions AND NOT onmarket Then
If marketposition < 1 AND OTD Then
BUY AT MARKET
marketposition = 1
EndIf
If marketposition > -1 AND OTD Then
SELLSHORT AT MARKET
marketposition = -1
EndIf
EndIf
Hi, I’ve used this old post to solve the problem of not having more than one trade on the same day, unfortunately, I still could have one trade long and another one short, can you suggest to me how to solve that? Many thanks for considering my request.
Stefano
and like this
if IntradayBarIndex =0 THEN
NBtrade=0
ENDIF
if (longonmarket[1]=0 and longonmarket )or(SHORTONMARKET[1]=0 and SHORTONMARKET )THEN
NBtrade=1
endif
if condition and nbtrade<1 THEN
buy 1 CONTRACTS AT MARKET
ENDIF
if condition and nbtrade<1 THEN
SELLSHORT 1 CONTRACTS AT MARKET
endif