Quick Question – One order per day
Forums › ProRealTime English forum › ProOrder support › Quick Question – One order per day
- This topic has 11 replies, 3 voices, and was last updated 8 years ago by Cosmic1.
-
-
05/19/2016 at 7:30 AM #731905/19/2016 at 8:45 AM #7323
Hi Cosmic1,
12345678910111213DEFPARAM CUMULATEORDERS = FALSEIF TIME=090000 THENmyLOT = 1ENDIFIF ONMARKET THENmyLOT = 0ENDIFIF NOT ONMARKET AND myConditions THENBUY myLOT CONTRACT AT MARKETENDIFTry it and let me know if works for you!
Cheers
1 user thanked author for this post.
05/19/2016 at 9:38 AM #7327Thanks for the quick reply. Unsure of how to get it to work within this code…
12345678910111213141516171819202122232425262728// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATAFTER = 160000// Conditions to enter long positionsindicator1 = closeindicator2 = BollingerDown[20](close)c1 = (indicator1 CROSSES OVER indicator2)IF c1 AND HOUR >=08 AND HOUR <=15.5 THENBUY 2 PERPOINT AT MARKETENDIF// Conditions to enter short positionsindicator5 = closeindicator6 = BollingerUp[20](close)c3 = (indicator5 CROSSES OVER indicator6)IF c3 AND HOUR >=08 AND HOUR <=15.5 THENSELLSHORT 2 PERPOINT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 20SET TARGET pPROFIT 40//SET STOP TRAILING 405/19/2016 at 2:14 PM #7351Hi, this is an usual question, we should made a code snippet for that within a blog article! 🙂
Just flag whenever your first trade occur and reset this variable each new day. This variable must be also part of your conditional statement to launch a trade of course, here is your code with these modifications :
1234567891011121314151617181920212223242526272829303132333435// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATAFTER = 160000//reset the variable each new dayif intradaybarindex = 0 thenalreadytraded = 0endif// Conditions to enter long positionsindicator1 = closeindicator2 = BollingerDown[20](close)c1 = (indicator1 CROSSES OVER indicator2)IF c1 AND HOUR >=08 AND HOUR <=15.5 AND alreadytraded=0 THENBUY 2 PERPOINT AT MARKETalreadytraded=1ENDIF// Conditions to enter short positionsindicator5 = closeindicator6 = BollingerUp[20](close)c3 = (indicator5 CROSSES OVER indicator6)IF c3 AND HOUR >=08 AND HOUR <=15.5 AND alreadytraded=0 THENSELLSHORT 2 PERPOINT AT MARKETalreadytraded=1ENDIF// Stops and targetsSET STOP pLOSS 20SET TARGET pPROFIT 40//SET STOP TRAILING 41 user thanked author for this post.
05/19/2016 at 2:49 PM #735805/19/2016 at 5:03 PM #7389We start defining how many points
1x = 1*PipSize // Points above today high or under today lowAnd then we set high and low of current day
12todayhigh = DHigh(0)todaylow = DLow(0)And last we set orders
1234IF myconditions thenbuy 1 contract at todayhigh+x STOPsellshort 1 contract at todaylow-x STOPENDIF1 user thanked author for this post.
05/19/2016 at 5:09 PM #7390Your full code with this implement should be like this:
123456789101112131415161718192021222324252627282930313233343536373839404142// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATAFTER = 160000// Parametersx = 1 * PipSize // Should be changed "1" to your desired number of pips.// Variablestodayhigh = DHigh(0)todaylow = DLow(0)//reset the variable each new dayif intradaybarindex = 0 thenalreadytraded = 0endif// Conditions to enter long positionsindicator1 = closeindicator2 = BollingerDown[20](close)c1 = (indicator1 CROSSES OVER indicator2)IF c1 AND HOUR >=08 AND HOUR <=15.5 AND alreadytraded=0 THENBUY 2 PERPOINT AT todayhigh+x STOPalreadytraded=1ENDIF// Conditions to enter short positionsindicator5 = closeindicator6 = BollingerUp[20](close)c3 = (indicator5 CROSSES OVER indicator6)IF c3 AND HOUR >=08 AND HOUR <=15.5 AND alreadytraded=0 THENSELLSHORT 2 PERPOINT AT todaylow-x STOPalreadytraded=1ENDIF// Stops and targetsSET STOP pLOSS 20SET TARGET pPROFIT 40//SET STOP TRAILING 41 user thanked author for this post.
05/19/2016 at 9:13 PM #742405/20/2016 at 8:31 AM #744105/20/2016 at 8:54 AM #7447Hi Cosmic, we are talking about something like you ask here:
http://www.prorealcode.com/topic/coding-for-high-and-low-between-set-hours/
Have a look
😉
05/21/2016 at 2:56 PM #7636Hey Adolfo, Had a look but unsure of how to get this working.
I want to look at the highest and lowest price for the range 1430-1700 for the current day.
Then I will take a breakout of that range long or short on the same day.
I have tried many things but cannot get it to work! Any help greatly appreciated.
05/21/2016 at 4:14 PM #7639 -
AuthorPosts