MA crossover: entry + 15 points query
Forums › ProRealTime English forum › ProOrder support › MA crossover: entry + 15 points query
- This topic has 4 replies, 2 voices, and was last updated 5 years ago by CJB64.
-
-
04/17/2019 at 4:25 PM #96725
Hi,
Complete newbie here so sorry if this is a silly question. I have looked in the forum but can not find a way to code it. I am trying to do the following:
Buy conditions:
ma5 crosses over ma15 AND DI+ > DI- then buy at *crossover price plus 15 points* at 5 per point
Sell conditions:
ma5 crosses under ma15 AND DI- > DI+ then buy at *crossover price minus 15 points* at 5 per point
I am struggling to work out the part in asterixes! So for example if ma5 crosses over ma15 at 12000 then providing the DI+ > DI-, I want to enter the trade at a price of 12015, hope that makes sense! Any help much appreciated!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.DEFPARAM FLATBEFORE = 134000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 180000// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 134000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 170000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions to enter long positionsindicator1 = ExponentialAverage[5](close)indicator2 = ExponentialAverage[15](close)c1 = (indicator1 CROSSES OVER indicator2)indicator3 = DIplus[14](close)indicator4 = DIminus[14](close)c2 = (indicator3 >= indicator4)IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 5 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator5 = ExponentialAverage[5](close)indicator6 = ExponentialAverage[15](close)c3 = (indicator5 CROSSES UNDER indicator6)indicator7 = ExponentialAverage[15](close)c4 = (close <= indicator7)IF c3 OR c4 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator8 = ExponentialAverage[5](close)indicator9 = ExponentialAverage[15](close)c5 = (indicator8 CROSSES UNDER indicator9)indicator10 = DIminus[14](close)indicator11 = DIplus[14](close)c6 = (indicator10 >= indicator11)IF (c5 AND c6) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENSELLSHORT 5 PERPOINT AT MARKETENDIF// Conditions to exit short positionsindicator12 = ExponentialAverage[5](close)indicator13 = ExponentialAverage[15](close)c7 = (indicator12 CROSSES OVER indicator13)indicator14 = ExponentialAverage[15](close)c8 = (close >= indicator14)IF c7 OR c8 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 1004/18/2019 at 8:07 AM #9673804/18/2019 at 12:39 PM #96753Hi Nicholas,
Thanks for your help, deally they would exist until the ma’s crossover again and at that point would cancel the opposing trade and take the new trade (if it has passed the 15points from crossover price). Hope that makes sense!
04/18/2019 at 2:25 PM #96757here is the code:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.DEFPARAM FLATBEFORE = 134000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 180000// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 134000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 170000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions to enter long positionsindicator1 = ExponentialAverage[5](close)indicator2 = ExponentialAverage[15](close)c1 = (indicator1 CROSSES OVER indicator2)indicator3 = DIplus[14](close)indicator4 = DIminus[14](close)c2 = (indicator3 >= indicator4)IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENdir = 1level = close+15*pointsizeENDIFif dir=1 thenbuy 5 perpoint at level stopendif// Conditions to exit long positionsindicator5 = ExponentialAverage[5](close)indicator6 = ExponentialAverage[15](close)c3 = (indicator5 CROSSES UNDER indicator6)indicator7 = ExponentialAverage[15](close)c4 = (close <= indicator7)IF c3 OR c4 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator8 = ExponentialAverage[5](close)indicator9 = ExponentialAverage[15](close)c5 = (indicator8 CROSSES UNDER indicator9)indicator10 = DIminus[14](close)indicator11 = DIplus[14](close)c6 = (indicator10 >= indicator11)IF (c5 AND c6) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENdir = -1level = close-15*pointsizeENDIFif dir=-1 thensellshort 5 perpoint at level stopendif// Conditions to exit short positionsindicator12 = ExponentialAverage[5](close)indicator13 = ExponentialAverage[15](close)c7 = (indicator12 CROSSES OVER indicator13)indicator14 = ExponentialAverage[15](close)c8 = (close >= indicator14)IF c7 OR c8 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 101 user thanked author for this post.
04/18/2019 at 4:17 PM #96764 -
AuthorPosts
Find exclusive trading pro-tools on