Code check please – keep me in the trade if a stoploss is hit?
Forums › ProRealTime English forum › ProOrder support › Code check please – keep me in the trade if a stoploss is hit?
- This topic has 5 replies, 3 voices, and was last updated 6 years ago by Nicolas.
-
-
11/24/2017 at 1:48 PM #53850
Hi guys, Could I just ask for someone to cast an eye over this code to see if there are any issues with it. For example, will it keep me in the trade if a stoploss is hit?
123456789101112131415161718192021222324252627282930313233343536373839404142434445// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[14](close)indicator2 = Average[30](close)c1 = (indicator1 > indicator2)indicator3 = Average[30](close)indicator4 = Average[50](close)c2 = (indicator3 > indicator4)indicator5 = Average[14](close)c3 = (close CROSSES UNDER indicator5)indicator6 = Average[30](close)c4 = (close > indicator6)IF c1 AND c2 AND c3 AND c4 THENBUY 1 PERPOINT AT MARKETENDIFIF c1 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator7 = Average[14](close)indicator8 = Average[30](close)c5 = (indicator7 < indicator8)indicator9 = Average[30](close)indicator10 = Average[50](close)c6 = (indicator9 < indicator10)indicator11 = Average[14](close)c7 = (close CROSSES OVER indicator11)indicator12 = Average[30](close)c8 = (close < indicator12)IF c5 AND c6 AND c7 AND c8 THENSELLSHORT 1 PERPOINT AT MARKETENDIFIF c2 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 25 ptrailing 25SET TARGET pPROFIT 150Thanks,
11/24/2017 at 4:09 PM #53866STOP LOSS is an order to close a trade, so when it’s entered your trade will end.
Line 44 cannot be written that way (despite what PRT documentation says), you have to either write one of these (your choice):
12SET STOP pLOSS 25SET STOP ptrailing 25Roberto
11/24/2017 at 4:18 PM #53867There are some duplicates, lines 5-14 can be written:
12345678910indicator1 = Average[14](close)indicator2 = Average[30](close)c1 = (indicator1 > indicator2)//indicator3 = Average[30](close)indicator4 = Average[50](close)c2 = (indicator2 > indicator4)indicator5 = Average[14](close)c3 = (close CROSSES UNDER indicator5)//indicator6 = Average[30](close)c4 = (close > indicator2)For the rest, it’s your strategy, try to test and optimize it, compare it to other strategiesyou may find here and over the web and… have fun autotrading!
11/24/2017 at 4:46 PM #53869Hi Roberto,
Thanks very much for your help. The Simplified creator in PRT codes it as
12// Stops and targetsSET STOP pLOSS 25 pTRAILING 25Are you saying that’s incorrect and won’t work as a trailing stop 25 points behind profit? If so that is a pretty major flaw in their software right?
11/24/2017 at 6:22 PM #5387311/27/2017 at 5:44 PM #54159 -
AuthorPosts