Can anyone help me with some basic code?
I am looking to backtest a simple MA cross system whilst incorporating an MACD signal as the basis for a strategy.
I need the MACD line to go above / below 3 and then come back across the 0 line (indicating a MA cross) for it to take a position. Condition 1 needs to be met before condition 2 is considered. My code is the following:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = MACDline[12,33,60](close)
c1 = (indicator1 >= 3.0)
indicator2 = MACDline[12,33,60](close)
c2 = (indicator2 CROSSES OVER 0.0)
IF c1 AND c2 THEN
BUY 1 SHARES AT MARKET
ENDIF
// Stops and targets
I need C1 to be met before C2 is considered. I can't seem to do this. I put "THEN" where the "AND" is and it doesn't work.
Can anyone assist?
I am looking to backtest a simple MA cross system whilst incorporating an MACD signal as the basis for a strategy.
I need the MACD line to go above / below 3 and then come back across the 0 line (indicating a MA cross) for it to take a position. Condition 1 needs to be met before condition 2 is considered. My code is the following:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = MACDline[12,33,60](close)
c1 = (indicator1 >= 3.0)
indicator2 = MACDline[12,33,60](close)
c2 = (indicator2 CROSSES OVER 0.0)
IF c1 AND c2 THEN
BUY 1 SHARES AT MARKET
ENDIF
// Stops and targets
I need C1 to be met before C2 is considered. I can't seem to do this. I put "THEN" where the "AND" is and it doesn't work.
Can anyone assist?