使用自动化代码无法正确执行

时间:2018-12-16 06:12:09

标签: python

当10 ema越过20和50时,我需要一个代码来购买;当10越过20和50时,我需要一个代码。

此代码存在问题;

  // Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated

// Conditions to enter long positions
indicator1 = ExponentialAverage[10](close)
indicator2 = ExponentialAverage[20](close)
c1 = (indicator1 CROSSES OVER indicator2 and  )
  indicator3 = ExponentialAverage[10](close)
indicator4 = ExponentialAverage[50](close)
c2 = (indicator3 CROSSES OVER indicator4)

IF c1 and c2 THEN
BUY 10 CONTRACT AT MARKET
ENDIF

// Conditions to exit long positions
indicator5 = ExponentialAverage[10](close)
indicator6 = ExponentialAverage[20](close)
c3 = (indicator5 CROSSES UNDER indicator6)
indicator7 = ExponentialAverage[10](close)
indicator8 = ExponentialAverage[50](close)
c4 = (indicator7 CROSSES UNDER indicator8)

IF c3 AND c4 THEN
SELL AT MARKET
ENDIF

只有在10 20 50正好同时穿越时才买入。我不希望那样,我需要的是不必同时穿越两者时就购买。而卖方则相反。

谢谢

0 个答案:

没有答案