1 TRADE PER DAY
Forums › ProRealTime English forum › ProOrder support › 1 TRADE PER DAY
- This topic has 11 replies, 5 voices, and was last updated 2 years ago by robertogozzi.
-
-
10/18/2021 at 11:16 AM #179862
Hi there,
This forum has been incredibly useful so far for a lot of things so thank you.
I have seen a couple of posts regarding the 1 trade per day coding but non of them seem to work for me so I was wondering if there was just a standard code you can input into the strategy?
Many thanks
10/18/2021 at 11:39 AM #17986310/18/2021 at 2:37 PM #17987310/18/2021 at 3:28 PM #179876Very strange, it should work.
In any case, try this snippet (Nicolas):
if intradaybarindex=0 or day<>day[1] then
count=0
endifif ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) or (not onmarket and onmarket[1])) then
count=count+1
endifThen:
if “myConditions” and count<1 then
…
10/18/2021 at 3:52 PM #179879Unfortunately that doesn’t work either. I’ll put the code below to see if anyone can figure out why…
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positions
indicator1 = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))
c1 = (close <= indicator1)
indicator2 = RSI[14](close)
c2 = (indicator2 <= 30)
indicator3 = MACDline[12,26,9](close)
c3 = (indicator3 <= -0.0015)
indicator4 = DLow(1)-2*(DHigh(1)-(DHigh(1) + DLow(1) + DClose(1))/3)
c4 = (close >= indicator4)if intradaybarindex=0 or day<>day[1] then
count=0
endifif ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) or (not onmarket and onmarket[1])) then
count=count+1
endif// initiate a new BUY order
if c1 AND c2 AND c3 AND c4 and count<1 THEN
BUY 10 CONTRACT AT MARKET
endif// Conditions to exit long positions
indicator5 = MACDline[12,26,9](close)
c5 = (indicator5 >= 0)IF c5 THEN
SELL AT MARKET
ENDIF// Conditions to enter short positions
indicator6 = MACDline[12,26,9](close)
c6 = (indicator6 >= 0.0015)
indicator7 = RSI[14](close)
c7 = (indicator7 >= 70)
indicator8 = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))
c8 = (close >= indicator8)
indicator9 = DHigh(1)+2*((DHigh(1) + DLow(1) + DClose(1))/3-DLow(1))
c9 = (close <= indicator9)IF c6 AND c7 AND c8 AND c9 and count<1 THEN
SELLSHORT 10 CONTRACT AT MARKET
ENDIF// Conditions to exit short positions
indicator10 = MACDline[12,26,9](close)
c10 = (indicator10 <= -0.0015)IF c10 THEN
EXITSHORT AT MARKET
ENDIF// Stops and targets
SET STOP pLOSS 6
SET TARGET pPROFIT 3210/18/2021 at 6:18 PM #179884OTD (One Trade per Day) works fine for me:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))c1 = (close <= indicator1)indicator2 = RSI[14](close)c2 = (indicator2 <= 30)indicator3 = MACDline[12,26,9](close)c3 = (indicator3 <= -0.0015)indicator4 = DLow(1)-2*(DHigh(1)-(DHigh(1) + DLow(1) + DClose(1))/3)c4 = (close >= indicator4)//if intradaybarindex=0 or day<>day[1] then//count=0//endif//if ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) or (not onmarket and onmarket[1])) then//count=count+1//endifOTD = (Barindex - TradeIndex(1) > IntradayBarIndex) //OR 1// initiate a new BUY order//if c1 AND c2 AND c3 AND c4 and count<1 THENif c1 AND c2 AND c3 AND c4 and OTD THENBUY 10 CONTRACT AT MARKETendif// Conditions to exit long positionsindicator5 = MACDline[12,26,9](close)c5 = (indicator5 >= 0)IF c5 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator6 = MACDline[12,26,9](close)c6 = (indicator6 >= 0.0015)indicator7 = RSI[14](close)c7 = (indicator7 >= 70)indicator8 = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))c8 = (close >= indicator8)indicator9 = DHigh(1)+2*((DHigh(1) + DLow(1) + DClose(1))/3-DLow(1))c9 = (close <= indicator9)//IF c6 AND c7 AND c8 AND c9 and count<1 THENIF c6 AND c7 AND c8 AND c9 and OTD THENSELLSHORT 10 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator10 = MACDline[12,26,9](close)c10 = (indicator10 <= -0.0015)IF c10 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 6SET TARGET pPROFIT 32try backtesting the same code, just removing the two comment slashes from line 21.
10/18/2021 at 6:53 PM #179888Hi Roberto,
Really appreciate you integrating the code for me!
It is quite strange because I backtested the code you sent back as well as the code I had previously and over 6 years yours bankrupted the account and the other made £4k haha. I tested again with a larger account size and it just had a steady stream of losses till money lost again. Is there something in the code that perhaps makes it sell? Again, I’m still very much learning but something doesn’t seem quite right! 🙂
10/19/2021 at 3:51 AM #1798941234567891011IF c6 AND c7 AND c8 AND c9 and OTD THENSELLSHORT 10 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator10 = MACDline[12,26,9](close)c10 = (indicator10 <= -0.0015)IF c10 THENEXITSHORT AT MARKETENDIFNo matter the origin, if you code like that (above), it becomes unreadable for yourself. Also, the result will be unpredictable (which is almost the same ;-)).
123456789// Conditions to exit short positionsindicator10 = MACDline[12,26,9](close)c10 = (indicator10 <= -0.0015)IF c6 AND c7 AND c8 AND c9 and OTD THENSELLSHORT 10 CONTRACT AT MARKETELSIF c10 THENEXITSHORT AT MARKETENDIFIf you code like the above, you depict mutual exclusive situations, which with the first example are not mutually exclusive at all.
A bit more tightly coded would be like this :
1234567891011121314IF c6 AND c7 AND c8 AND c9 and OTD THENSELLSHORT 10 CONTRACT AT MARKETELSE// Conditions to exit short positionsindicator10 = MACDline[12,26,9](close)c10 = (indicator10 <= -0.0015)If c10 THENEXITSHORT AT MARKETENDIFENDIFBut this still would leave you with all kind of doubts, and it should be like this :
1234567891011121314151617181920212223242526272829303132333435363738394041424344If Not OnMarket thenEnteredMarket = 0If Not EnteredMarket then // Superfluous here, but good habit.// Conditions to go Short.IF c6 AND c7 AND c8 AND c9 and OTD THENSELLSHORT 10 CONTRACT AT MARKETEnteredMarket = 1ENDIFENDIFIf Not EnteredMarket then // Nit superfluous at all.// Other conditions for going Short or ... Long.IF ... then// ...EnteredMarket = 1ENDIFENDIFENDIF // Not OnMarket ?If Not EnteredMarket then // A bit of overkill, but in certain situations even this is good habit.If ShortOnMarket then// Conditions to exit short positionsindicator10 = MACDline[12,26,9](close)c10 = (indicator10 <= -0.0015)If c10 THENEXITSHORT AT MARKETENDIFENDIF // ShortOnMarket ?ENDIF // Not EnteredMarket ?This leaves no doubt about what is happening and “what you are doing”;
Try to rebuild the code like this and you may automatically run into the culprit(s) why it is not working out, even before running your re-coded program.
Never think this is long-winded and a waste of time, because clarity above all !Good luck now !
10/19/2021 at 4:07 AM #179895I found a bug !
🙂12345678910111213If Not OnMarket thenEnteredMarket = 0If Not EnteredMarket then // Superfluous here, but good habit.// The above is wrong and it should be like this :EnteredMarket = 0If Not OnMarket thenIf Not EnteredMarket then // Superfluous here, but good habit.1 user thanked author for this post.
10/19/2021 at 10:58 AM #17993902/10/2022 at 3:28 PM #18801302/10/2022 at 3:51 PM #188014Thx, Roberto
but really dont know what you are meaning,
thx for your support
Why are you answering here? Please do NO scatter infor all over the forum! Keep posting in your own topic. Thanks 🙂
-
AuthorPosts
Find exclusive trading pro-tools on