Exemplo n.º 1
0
 protected override void CalcBar()
 {
     if (StrategyInfo.MarketPosition >= 0)
     {
         m_EbAtrSX.Send(Bars.Close[0] + this.AverageTrueRange(AtrLength) * NumAtrs);
     }
 }
 protected override void CalcBar()
 {
     if (StrategyInfo.MarketPosition <= 0)
     {
         m_EbDlrLX.Send(Bars.Close[0] - m_BigPointRisk);
     }
 }
Exemplo n.º 3
0
        protected override void CalcBar()
        {
            m_MP.Value = StrategyInfo.MarketPosition;

            if (m_MP.Value > 0)
            {
                if (m_MP[1] <= 0)
                {
                    m_StopPrice.Value = Bars.Low[0] - this.AverageTrueRange(AtrLength) * NumAtrs;
                    m_AF.Value        = AccfactorStep;
                    m_TradeHH.Value   = Bars.High[0];
                }
                else
                {
                    if (PublicFunctions.DoubleGreater(Bars.High[0], m_TradeHH.Value))
                    {
                        m_TradeHH.Value = Bars.High[0];
                    }
                    m_StopPrice.Value += m_AF.Value * (m_TradeHH.Value - m_StopPrice.Value);
                    if (PublicFunctions.DoubleGreater(m_TradeHH.Value, m_TradeHH[1]) &&
                        PublicFunctions.DoubleLess(m_AF.Value, AccFactorLimit))
                    {
                        m_AF.Value += PublicFunctions.Min(AccfactorStep, AccFactorLimit - m_AF.Value);
                    }
                }
                if (PublicFunctions.DoubleGreater(m_StopPrice.Value, Bars.Low[0]))
                {
                    m_StopPrice.Value = Bars.Low[0];
                }
                m_ParTrLX.Send(m_StopPrice.Value);
            }
        }
        protected override void CalcBar()
        {
            var m_avg   = m_AverageFC[0];
            var m_shift = NumAtrs * this.AverageTrueRange(Length);

            m_LowerBand.Value = m_avg - m_shift;
            if (Bars.CurrentBar > 1 && Price.CrossesUnder(m_LowerBand, ExecInfo.MaxBarsBack))
            {
                m_bSetupSE.Value    = true;
                m_CrossingLow.Value = Bars.Low[0];
            }
            else
            {
                if (m_bSetupSE.Value &&
                    (PublicFunctions.DoubleGreater(Price[0], m_avg) ||
                     PublicFunctions.DoubleLessEquals(Bars.Low[0], m_CrossingLow.Value - Bars.Point)))
                {
                    m_bSetupSE.Value = false;
                }
            }
            if (m_bSetupSE.Value)
            {
                m_KltChSE.Send(m_CrossingLow.Value - Bars.Point);
            }
        }
        protected override void CalcBar()
        {
            double m_avg   = m_AverageFC[0];
            double m_shift = NumAtrs * this.AverageTrueRange(Length);

            m_UpperBand.Value = m_avg + m_shift;   //UB


            if (Bars.CurrentBar > 1 && Price.CrossesOver(m_UpperBand, ExecInfo.MaxBarsBack)) //CROSS(C,HB);
            {
                m_bSetupLE.Value     = true;
                m_CrossingHigh.Value = Bars.High[0];  //HH
            }
            else
            {
                if (m_bSetupLE.Value &&
                    (PublicFunctions.DoubleLess(Price[0], m_avg) ||   //C<MA
                     PublicFunctions.DoubleGreaterEquals(Bars.High[0], m_CrossingHigh.Value + Bars.Point)))
                {
                    m_bSetupLE.Value = false;
                }
            }
            if (m_bSetupLE.Value)
            {
                m_KltChLE.Send(m_CrossingHigh.Value + Bars.Point);
            }
        }
 protected override void CalcBar()
 {
     if (StrategyInfo.MarketPosition >= 0)
     {
         m_EbPntSX.Send(Bars.Close[0] + RiskPoints * Bars.Point);
     }
 }
 protected override void CalcBar()
 {
     if (m_InitialPass &&
         ((Bars.Info.Resolution.Type.IsDayBased() &&
           Bars.Time[0].Date == PrevBarTime.Date) ||
          Bars.Time[0] == PrevBarTime))
     {
         if (IsLongOrder)
         {
             if (PublicFunctions.DoubleGreater(MyEntryPrice, OpenPriceEntryBar))
             {
                 m_StopBuy.Send(MyEntryPrice, Quantity);
             }
             else
             {
                 m_LimitBuy.Send(MyEntryPrice, Quantity);
             }
         }
         else
         {
             if (PublicFunctions.DoubleLess(MyEntryPrice, OpenPriceEntryBar))
             {
                 m_StopShort.Send(MyEntryPrice, Quantity);
             }
             else
             {
                 m_LimitShort.Send(MyEntryPrice, Quantity);
             }
         }
     }
     if (m_InitialPass && Bars.LastBarOnChart)
     {
         m_InitialPass = false;
     }
 }
Exemplo n.º 8
0
 protected override void CalcBar()
 {
     m_ParabolicSAR.Call();
     if (m_oposition.Value == 1)
     {
         m_ParSE.Send(m_oparop.Value);
     }
 }
 protected override void CalcBar()
 {
     m_HigherBand.Value = Bars.Close.BollingerBandCustom(Length, NumDevsUp);
     if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_HigherBand, ExecInfo.MaxBarsBack))
     {
         m_BBandSE.Send(m_HigherBand.Value);
     }
 }
 protected override void CalcBar()
 {
     m_LowerBand.Value = Bars.Close.BollingerBandCustom(Length, -NumDevsDn);
     if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack)) //cross(C, LB)
     {
         m_BBandLE.Send(m_LowerBand.Value);
     }
 }
Exemplo n.º 11
0
 protected override void CalcBar()
 {
     if (tlRef != null && tlRef.Exist)
     {
         if (Bars.Time[0] >= m_BeginTime && PublicFunctions.DoubleLess(Bars.High[0], tlRef.PriceValue(Bars.Time[0])))
         {
             m_BuyOrder.Send(tlRef.PriceValue(Bars.TimeNextBar()));
         }
     }
 }
Exemplo n.º 12
0
        protected void EMarketPositionSideFlat(double _ddema, double _wdema)
        {
            //Output.WriteLine("EMarketPositionSideFlat");

            if (BarsOfData(2).High[0] > _wdema)
            {
                return;
            }

            FirstEnterDynamicValue = _wdema + (_wdema * (FirstEnterRate / 100));         // first enter price calculation
            StopLossDynamicValue   = _wdema - (_wdema * (SL1Rate / 100));                // initial stop price calcualtion

            InitialContractSizeDynamicValue = CalculateInitialContractSize(FirstEnterDynamicValue, StopLossDynamicValue);

            //Output.WriteLine("Enter price: " + FirstEnterDynamicValue + "Stoploss: " + StopLossDynamicValue);

            FE.Send(FirstEnterDynamicValue, InitialContractSizeDynamicValue);            // Place enter stop order
            SL1.Send(StopLossDynamicValue, InitialContractSizeDynamicValue);             //Place stoploss order
        }
Exemplo n.º 13
0
        protected override void CalcBar()
        {
            double FloorProfit = IsPositionBasis ? FloorAmt : FloorAmt * StrategyInfo.MarketPosition;
            double SellPrice   = m_LowestFC[0];

            if (StrategyInfo.MarketPosition > 0 &&
                PublicFunctions.DoubleGreaterEquals(this.MaxPositionProfit(), FloorProfit))
            {
                m_ChTrLX.Send(SellPrice);
            }
        }
        protected override void CalcBar()
        {
            double FloorProfit = IsPositionBasis ? FloorAmt : -StrategyInfo.MarketPosition * FloorAmt;
            double CoverPrice  = m_HighestFC[0];

            if (StrategyInfo.MarketPosition < 0 &&
                PublicFunctions.DoubleGreaterEquals(this.MaxPositionProfit(), FloorProfit))
            {
                m_ChTrSX.Send(CoverPrice);
            }
        }
Exemplo n.º 15
0
 protected override void CalcBar()
 {
     if (tlref != null && tlref.Exist)
     {
         if (Bars.Time[0] >= m_BeginTime &&
             PublicFunctions.DoubleGreater(Bars.Low[0], tlref.PriceValue(Bars.Time[0])))
         {
             m_ShortOrder.Send(tlref.PriceValue(Bars.TimeNextBar()));
         }
     }
 }
Exemplo n.º 16
0
        protected override void CalcBar()
        {
            m_mom.Value = Price.Momentum(Length);
            double m_accel = m_mom.Momentum(1);

            if (PublicFunctions.DoubleGreater(m_mom.Value, 0) &&
                PublicFunctions.DoubleGreater(m_accel, 0))
            {
                m_MomLE.Send(Bars.High[0] + Bars.Point);
            }
        }
Exemplo n.º 17
0
        protected override void CalcBar()
        {
            m_mom.Value = Price.Momentum(Length);
            double m_accel = m_mom.Momentum(1);

            if (PublicFunctions.DoubleLess(m_mom.Value, 0) &&
                PublicFunctions.DoubleLess(m_accel, 0))
            {
                m_MomSE.Send(Bars.Low[0] - Bars.Point);
            }
        }
Exemplo n.º 18
0
 protected override void CalcBar()
 {
     CurSpecOrdersMode = ESpecOrdersMode.PerContract;
     if (StrategyInfo.MarketPosition < 0)
     {
         GenerateStopLoss(this.EntryPrice() * StopLossPct);
     }
     else
     {
         m_PctStopSX_eb.Send(Bars.Close[0] * (1.0 + StopLossPct));
     }
 }
Exemplo n.º 19
0
        protected void ManageStrategyStoploss(double _wdema)
        {
            DailyBarCounter++;

            if (DailyBarCounter < TrailingSLCalcBarStart)
            {
                SL1.Send(StopLossDynamicValue, InitialContractSizeDynamicValue);                 //Place basic stoploss order
                return;
            }

            double TrailingStopLoss = _wdema - (_wdema * (TrailingSL1WeeklyRate / 100));

            TralingSL1.Send(TrailingStopLoss, InitialContractSizeDynamicValue);             //Place trailing stoploss order
        }
Exemplo n.º 20
0
        protected override void CalcBar()
        {
            double AtrVal = this.AverageTrueRange(AtrLength) * NumAtrs;

            m_mp.Value = StrategyInfo.MarketPosition;
            if (m_mp.Value < 0)
            {
                if (m_mp[1] >= 0 || PublicFunctions.DoubleLess(Bars.Low[0], m_PosLow.Value))
                {
                    m_PosLow.Value = Bars.Low[0];
                }
                m_AtrSX.Send(m_PosLow.Value + AtrVal);
            }
            else
            {
                m_AtrSX_eb.Send(Bars.Low[0] + AtrVal);
            }
        }
 protected override void CalcBar()
 {
     if (m_SwingHigh[0] > 0)
     {
         m_Setup.Value     = true;
         m_PivotHigh.Value = Bars.High[Strength];
     }
     else
     {
         if (m_Setup.Value && PublicFunctions.DoubleGreaterEquals(Bars.High[0], m_PivotHigh.Value + Bars.Point))
         {
             m_Setup.Value = false;
         }
     }
     if (m_Setup.Value)
     {
         m_PivRevLE.Send(m_PivotHigh.Value + Bars.Point);
     }
 }
Exemplo n.º 22
0
 protected override void CalcBar()
 {
     m_mp.Value = StrategyInfo.MarketPosition;
     if (m_mp.Value < 0)
     {
         if (m_mp[1] >= 0)
         {
             m_TargetPrice.Value = this.EntryPrice() - this.AverageTrueRange(AtrLength) * NumAtrs;
         }
         if (this.BarsSinceEntry() < NumBars)
         {
             m_ATTSX_Tgt.Send(m_TargetPrice.Value);
         }
         else
         {
             m_ATTSX_Trl.Send(Bars.High[0]);
         }
     }
 }
 protected override void CalcBar()
 {
     if (m_SwingLow[0] > 0)
     {
         m_Setup.Value    = true;
         m_PivotLow.Value = Bars.Low[Strength];
     }
     else
     {
         if (m_Setup.Value && PublicFunctions.DoubleLessEquals(Bars.Low[0], m_PivotLow.Value - Bars.Point))
         {
             m_Setup.Value = false;
         }
     }
     if (m_Setup.Value)
     {
         m_PivRevSE.Send(m_PivotLow.Value - Bars.Point);
     }
 }
        protected override void CalcBar()
        {
            var AtrValue = this.AverageTrueRange(AtrLength) * NumAtrs; //3*ATR

            m_mp.Value = StrategyInfo.MarketPosition;

            if (m_mp.Value > 0)
            {
                if (m_mp[1] <= 0 || PublicFunctions.DoubleGreater(Bars.High[0], m_PosHigh.Value))
                {
                    m_PosHigh.Value = Bars.High[0];       //store historial H
                }
                m_AtrLX.Send(m_PosHigh.Value - AtrValue); //HH -3*ATR
            }
            else
            {
                m_AtrLX_eb.Send(Bars.High[0] - AtrValue);
            }
        }
 protected override void CalcBar()
 {
     if (m_InitialPass &&
         Bars.Time[0].Date == PrevBarTime.Date &&
         (Bars.Info.Resolution.Type.IsDayBased() || Bars.Time[0] == PrevBarTime))
     {
         if (Environment.IsAutoTradingMode)
         {
             ChangeMarketPosition((IsLongOrder ? 1 : -1) * Quantity, MyEntryPrice);
         }
         else
         if (IsLongOrder)
         {
             if (PublicFunctions.DoubleGreater(MyEntryPrice, OpenPriceEntryBar))
             {
                 m_StopBuy.Send(MyEntryPrice, Quantity);
             }
             else
             {
                 m_LimitBuy.Send(MyEntryPrice, Quantity);
             }
         }
         else
         {
             if (PublicFunctions.DoubleLess(MyEntryPrice, OpenPriceEntryBar))
             {
                 m_StopShort.Send(MyEntryPrice, Quantity);
             }
             else
             {
                 m_LimitShort.Send(MyEntryPrice, Quantity);
             }
         }
     }
     if (m_InitialPass && Bars.LastBarOnChart)
     {
         m_InitialPass = false;
     }
 }
Exemplo n.º 26
0
        protected override void CalcBar()
        {
            if (Bars.High[0] > day_high)
            {
                day_high = Bars.High[0];
            }

            if (Bars.Time[0].Hour == 11 || Bars.Time[0].Hour == 16 || Bars.Time[0].Hour == 17)
            {
                if (!double.IsNaN(buy_level) && Bars.Close[0] > buy_level - 100 && Bars.Close[0] < buy_level && StrategyInfo.MarketPosition == 0)
                {
                    tradesCount++;
                    // Output.WriteLine(string.Format("Close: {0} Level: {1} Trades: {2} BarN: {3}", Bars.Close[0], buy_level, tradesCount, Bars.CurrentBar));
                    buy_order.Send();
                    stop_price = Bars.Low[0] - 200;
                    take_price = Bars.Close[0] + 5000;
                    return;
                }
            }

            take_profit.Send(take_price);
            stop_loss.Send(stop_price);

            if (Bars.LastBarInSession && StrategyInfo.MarketPosition != 0)
            {
                GenerateExitOnClose();
            }

            if (Bars.LastBarInSession)
            {
                //Output.WriteLine(string.Format("Buy price: {0}. Day High: {1}", buy_level, day_high));
                buy_level = GetBuyLevel();
                orderSent = false;
                day_high  = double.NegativeInfinity;
            }
        }
 protected override void CalcBar()
 {
     m_VltOpenSE.Send(Bars.OpenNextBar() - m_AverageFC[0] * NumRanges);
 }
 protected override void CalcBar()
 {
     m_VltClsSX.Send(Bars.Close[0] + this.AverageTrueRange(Length) * NumAtrs);
 }
Exemplo n.º 29
0
 protected override void CalcBar()
 {
     m_ExitOrder.Send(TriggerPrice, ExitQuantity);
 }
 protected override void CalcBar()
 {
     m_PChLE.Send(m_HighestFC[0] + Bars.Point);
 }