Guys
Very new to all this but managed to come up with the below algo.
Can anyone advise how do i change the below code so it does the following points
Risk Management – Auto calculates £ per point based upon 10% risk to my capital account. e.g £10,000 capital would risk £1000.
stop loss = 1* ATR
take profit = 5* ATR
so if ATR is 10, the £ per point would be £100 (stop loss = 1* 10*£100 = £1000) which is my risk management strategy.
// Conditions to enter long positions
indicator1 = Average[90](close)
c1 = (close[1] > indicator1[1])
indicator2 = MACDline[12,26,9](close)
indicator3 = ExponentialAverage[9](indicator2)
c2 = (indicator2[1] CROSSES OVER indicator3[1])
IF c1 AND c2 THEN
BUY 100 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator4 = MACDline[12,26,9](close)
indicator5 = ExponentialAverage[9](indicator4)
c3 = (indicator4[1] CROSSES UNDER indicator5[1])
IF c3 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator6 = Average[90](close)
c4 = (close[1] < indicator6[1])
indicator7 = MACDline[12,26,9](close)
indicator8 = ExponentialAverage[9](indicator7)
c5 = (indicator7[1] CROSSES UNDER indicator8[1])
IF c4 AND c5 THEN
SELLSHORT 100 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator9 = MACDline[12,26,9](close)
indicator10 = ExponentialAverage[9](indicator9)
c6 = (indicator9[1] CROSSES OVER indicator10[1])
IF c6 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 50
SET TARGET pPROFIT 200
To write code, please use the <> “insert PRT code” button, to make code easier to understand. Thank you.
/ Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = Average[90](close)
c1 = (close[1] > indicator1[1])
indicator2 = MACDline[12,26,9](close)
indicator3 = ExponentialAverage[9](indicator2)
c2 = (indicator2[1] CROSSES OVER indicator3[1])
IF c1 AND c2 THEN
BUY 100 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator4 = MACDline[12,26,9](close)
indicator5 = ExponentialAverage[9](indicator4)
c3 = (indicator4[1] CROSSES UNDER indicator5[1])
IF c3 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator6 = Average[90](close)
c4 = (close[1] < indicator6[1])
indicator7 = MACDline[12,26,9](close)
indicator8 = ExponentialAverage[9](indicator7)
c5 = (indicator7[1] CROSSES UNDER indicator8[1])
IF c4 AND c5 THEN
SELLSHORT 100 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator9 = MACDline[12,26,9](close)
indicator10 = ExponentialAverage[9](indicator9)
c6 = (indicator9[1] CROSSES OVER indicator10[1])
IF c6 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 50
SET TARGET pPROFIT 200
Hi – I used the <>”insert PRT button” – thanks for advising that. much appreciated
What needs to change so it automatically calculates the £ per point based upon my risk management strategy (10% risk loss of capital per trade) and max loss is 1* ATR and take profit at 5*ATR