I have been using back testing for quite a while, I’ve just changed a strategy and now I get no results even when I change the code to be very simple. not sure what’s wrong here . AUD/USD mini
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Buy Price
Startprice = Tradeprice
TakeProfit = (Startprice + 0.0008)
Buyit = 1
// Conditions to enter long positions
indicator1 = MACDline[12,26,9](close)
indicator3 = MACD[12,26,9](close)
indicator4 = Average[18](close)
indicator5 = MACDSignal[12,26,9](close)
c1 = (indicator1 > indicator1[1])
c2 = (indicator1 > indicator3)
c3 = (close > indicator4)
c7 = (indicator1 > indicator5)
IF c1 and c2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator6 = (close > Takeprofit)
c4 = (indicator1 < indicator1[1])
c5 = (close > Startprice)
c6 = indicator6
IF c4 or c6 THEN
SELL AT MARKET
ENDIF
As it’s on Forex, Line 6 needs to be as below … assuming you even mean that as 0.0008 ia a very small increase??
TakeProfit = (Startprice + 0.0008*pointsize)
Thanks GraHal this has worked as well as a variable in the past but I’ll give it a try. but this is more about taking the trade not closing the position .. I’m struggling to even start a trade .. thank you ..
Use below at bottom of your code so you can see when C1 and c2 are true to check for coincidence.
MyBuy - C1 AND C2
GRAPH MyBuy
Typo in above, should as below …
MyBuy = C1 AND C2
GRAPH MyBuy
JSParticipant
Senior
Hi @crankbuddy
There is an error in the code, namely line 29 “c6=indicator6″…
This condition is always true, so the position is immediately closed again…
Remove line 29 and change line 31 to “If c4 then”
Thanks JS, I removed the code and it fixed the problem, and Thanks GraHal for the GRAPH tip, it’s handy and I will use it in future coding.