I made this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
DEFPARAM CumulateOrders = false MinLookBack = 3 //crossing must have occured at least these bars before PullBack MaxLookBack = 10 //crossing must have occured at most these bars before PullBack MA50 = average[50,0](close) x = close crosses over ma50 IF x OR (close > MA50 AND low < MA50) THEN //when a pullback occurs... IF summation[MinLookBack](x[1]) = 0 THEN IF summation[MaxLookBack](x[MinLookBack + 1]) AND Not OnMarket AND close > open THEN BUY 1 CONTRACT AT MARKET SET STOP pLOSS 50 SET TARGET pPROFIT 200 ENDIF ENDIF ENDIF graph minlookback graph maxlookback graph x graph barindex |
|
MA50 = average[50,0](close) RETURN close CROSSES OVER MA50 |
On May 15th, at 17:00 GRAPH (ProOrder) visualized variable X as being 1, while the indicator (ProBuilder) had not returned any crossing at that time.