Ejemplo n.º 1
0
        internal void TradeUsing(SmaValues inputSmaValues, string intervalUseReason = "")
        {
            var curPrice = CurrentValues.CurrentBufferedPrice;

            if (inputSmaValues.Buy == true)
            {
                if (!CurrentValues.BuyOrderFilled) //if not already bought
                {
                    if (!CurrentValues.WaitingBuyOrSell)
                    {
                        CurrentValues.WaitingBuyOrSell = true;
                        Logger.WriteLog(intervalUseReason);
                        Logger.WriteLog(inputSmaValues.BuyReason);
                        LastBuyAtPrice = curPrice;
                        Buy();
                    }
                }
            }


            if (inputSmaValues.Sell == true)
            {
                if (!CurrentValues.SellOrderFilled) //if not already sold
                {
                    if (!CurrentValues.WaitingBuyOrSell)
                    {
                        CurrentValues.WaitingBuyOrSell = true;
                        Logger.WriteLog(intervalUseReason);
                        Logger.WriteLog(inputSmaValues.SellReason);
                        LastSellAtPrice = curPrice;
                        Sell();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //use big, medium or small sma to sell depending on market conditions
        public TradeStrategyE(ref ContextValues inputContextValues, IntervalValues intervalValues) : base(ref inputContextValues)
        {
            SetCurrentAction(inputContextValues.CurrentAction);
            LastBuyAtPrice  = inputContextValues.CurrentBufferedPrice;
            LastSellAtPrice = 0;



            BigIntervalSmaValues = new SmaValues("BigInterval", ref inputContextValues, intervalValues.LargeIntervalInMin,
                                                 intervalValues.LargeSmaSlices, intervalValues.MediumSmaSlice, intervalValues.SmallSmaSlices);
            SmallIntervalSmaValues = new SmaValues("SmallInterval", ref inputContextValues, intervalValues.MediumIntervalInMin,
                                                   intervalValues.LargeSmaSlices, intervalValues.MediumSmaSlice, intervalValues.SmallSmaSlices);
            TinyIntervalSmaValues = new SmaValues("TinyInterval", ref inputContextValues, intervalValues.SmallIntervalInMin,
                                                  intervalValues.LargeSmaSlices, intervalValues.MediumSmaSlice, intervalValues.SmallSmaSlices);


            inputContextValues.WaitTimeAfterBigSmaCrossInMin = intervalValues.LargeIntervalInMin;
            //LargeSmaGroup = new SmaGroup();
            //LargeSmaGroup.SetGroup(SmallIntervalSmaValues, BigIntervalSmaValues);

            //SmallSmaGroup = new SmaGroup();
            //SmallSmaGroup.SetGroup(TinyIntervalSmaValues, SmallIntervalSmaValues);

            try
            {
                SmallPriceIncreasedPercentage = Properties.Settings.Default.StrategyE_SmallPriceIncreasedPercent;
                BigPriceIncreasedPercentage   = Properties.Settings.Default.StrategyE_BigPriceIncreasedPercent;
            }
            catch (Exception)
            {
                Logger.WriteLog("Couldnt read strategy E big and samll price change percentage values, using default of .75 and 1.75");
                SmallPriceIncreasedPercentage = 0.75m;
                BigPriceIncreasedPercentage   = 1.75m;
            }
        }