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?
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = 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 THEN
BUY 1 PERPOINT AT MARKET
ENDIF
IF c1 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator7 = 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 THEN
SELLSHORT 1 PERPOINT AT MARKET
ENDIF
IF c2 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 25 ptrailing 25
SET TARGET pPROFIT 150
Thanks,
STOP 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):
SET STOP pLOSS 25
SET STOP ptrailing 25
Roberto
There are some duplicates, lines 5-14 can be written:
indicator1 = 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!
Hi Roberto,
Thanks very much for your help. The Simplified creator in PRT codes it as
// Stops and targets
SET STOP pLOSS 25 pTRAILING 25
Are 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?
@Mattyj
To be perfectly clear, these 2 combined instructions are not possible with ProOrder through IG. But works ok in demo/paper trading.