Hello,
I’ve added a SMA to the profit curve of a system (whichever it is).
I’d like to test adding a condition for buying or selling.
A trade should only be triggered if the condition is met.
For the trade to be triggered, the profit curve must be greater than its moving average.
Is this possible? Any idea on how to translate this into code?
There you go:
ProfitMA = average[20,0](StrategyProfit)
Above = ProfitMA >= StrategyProfit
Below = ProfitMA < StrategyProfit
IF Not OnMarket THEN
IF Below THEN
BUY 1 CONTRACT AT MARKET
ELSIF Above THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
SET STOP pLOSS 50
SET TARGET pPROFIT 100
ENDIF
//
graph StrategyProfit coloured("Blue")
graph ProfitMA coloured("Red")
add the variables Above or Below to your entry conditions.