コード例 #1
0
        protected override int Init()
        {
            beat = new QuoteBeat();
            beat.Add(new Quote(Bid, Ask));

            isInitialize = true;

            return 1;
        }
コード例 #2
0
ファイル: MyExpertAdvisor.cs プロジェクト: Daiwv/forexsharp
        protected override int Init()
        {
            beat = new QuoteBeat();
            beat.Add(new Quote(Bid, Ask));

            isInitialize = true;

            return(1);
        }
コード例 #3
0
ファイル: MyExpertAdvisor.cs プロジェクト: Daiwv/forexsharp
        protected override int Start()
        {
            if (!isInitialize)
            {
                Init();
            }

            // should introduce event and directly buy or sell
            // should create new object for decision making.

            while (true)
            {
                RefreshRates();

                beat.Add(new Quote(Bid, Ask));

                PrintReport(beat);

                if (beat.LastDelta >= threshold)
                {
                    if (IsNoOpenOrder())
                    {
                        Console.WriteLine("No Open Order");
                        order = Buy(1);

                        order.ChangeStopLossInPoints(100);
                        order.ChangeTakeProfitInPoints(20);
                    }
                    else
                    {
                        if (IsAlreadyOpenBuy())
                        {
                            return(1);
                        }

                        order.Close();

                        order = Buy(1);
                        order.ChangeStopLossInPoints(100);
                        order.ChangeTakeProfitInPoints(20);
                    }
                }
                else if (Math.Abs(beat.LastDelta) >= threshold)
                {
                    if (IsNoOpenOrder())
                    {
                        Console.WriteLine("No Open Order");
                        order = Sell(1);
                        order.ChangeStopLossInPoints(100);
                        order.ChangeTakeProfitInPoints(20);
                    }
                    else
                    {
                        if (IsAlreadyOpenSell())
                        {
                            return(1);
                        }

                        order.Close();
                        order = Sell(1);
                        order.ChangeStopLossInPoints(100);
                        order.ChangeTakeProfitInPoints(20);
                    }
                }

                Thread.Sleep(500);
            }


            return(1);
        }