0

我正在使用 C# 编写一个交易系统。我的大部分逻辑是如果某些条件同时发生,则输入买入。

但在某些情况下,我需要一个排除逻辑:如果某些情况同时发生,则不购买。

我试图设置一个名为Falling1 = true;并设置的变量,Falling1=false;而同时出现不买条件。

然后在我需要的购买逻辑中Falling1=true;

namespace NinjaTrader.NinjaScript.Strategies
{
    public class JJcrossCode : Strategy
    {
        private bool Falling1;
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = @"Enter the description for your new custom Strategy here.";
                Name = "JJcrossCode";
                Falling1 = true;
            }
            else if (State == State.Configure)
            {
            }
            else if (State == State.DataLoaded)
            {
                SetProfitTarget(@"Short", CalculationMode.Ticks, 20);
            }
        }

        protected override void OnBarUpdate()
        {
        if (BarsInProgress != 0)
            return;
        if (CurrentBars[0] < 7)
            return;
        // Set 1
        if (Open[0] > Close[0] && High[0] < High[1] && Low[0] < Low[1])
        {
            Falling1 = false;
        }
        // Set 2
// 01-crossabovelower
        if (((CrossAbove(JurbolBBmacd1.Macd, JurbolBBmacd1.BollingerLower, 3))
&& (RSI1.Avg[0] < 67)&& (Falling1=true)
        {
            EnterLong(Convert.ToInt32(Size), @"Long");
        }
    }
}

问题是系统似乎无法识别&& (Falling1=true)// 01-crossabovelower,我猜我的代码中存在一些结构问题。

4

1 回答 1

3

你要

  && (Falling1==true)

你写它的方式你正在做一个任务

于 2019-09-25T21:39:18.050 回答