我一直在使用 2 条移动平均线交叉,这是非常直接的。我想在混合中添加三分之一,我试图找出在 4 根蜡烛或更少的时间内检查是否发生这种情况。
对于两个移动平均线,我使用了以下内容:
// if shift5MA > shift0MA
if (shift5MAArray[1] > shift0MAArray[1]) {
//if shift5MA < shift0MA VALID SELL
if (shift5MAArray[2] < shift0MAArray[2]) {
signal = "sell";
}
}
if (shift5MAArray[1] < shift0MAArray[1]) {
//if shift5MA > shift0MA
if (shift5MAArray[2] > shift0MAArray[2]) {
signal = "buy";
}
}
Run Code Online (Sandbox Code Playgroud)
我如何检查 3 条移动平均线何时在 4 根蜡烛或更少的时间内相互交叉,如图像中的三个交叉:
我正在尝试为我的游戏创建一个菜单,需要大量的效果UICollectionView,所以不是重新发明轮子,而是使用我从YouTube视频获得的集合视图,因为它接近我想要达到的目标.我的游戏有posterScene我在加载开始GameViewController,我怎么可以和我代替我posterScene collectionView的MenuViewContoller?
请查看下面的代码:
MenuViewController:
class MenuViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 0
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.backgroundColor = .red
cv.dataSource = self
cv.delegate = self
cv.isPagingEnabled = true
return cv
}()
let cellId = "cellId"
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(collectionView)
//use autolayout instead
collectionView.anchorToTop(top: view.topAnchor, left: view.leftAnchor, bottom: view.bottomAnchor, right: view.rightAnchor)
collectionView.register(PageCell.self, …Run Code Online (Sandbox Code Playgroud) 抱歉,如果这听起来太原始了。我似乎真的不明白等待 SKAction 在一个范围内是如何工作的。我看过一些帖子,但他们没有清楚地解释(据我理解)如何计算我的范围。例如,我看到以下范围:
SKAction.wait(forDuration: 2.5, withRange: 3.0), //Wait between 1.0 and 4.0 seconds
SKAction.wait(forDuration: 0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
Run Code Online (Sandbox Code Playgroud)
我不确定如何协调上述内容来计算 1.0 到 2.0 秒和 0.2 到 0.8 秒之间的等待时间。