Esempio n. 1
0
        /// <summary>
        /// Basic indicator example for SMA crossover
        /// </summary>
        public Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic(IDataSeries input)
        {
            if (IsInInit && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'OnInit()' method");
            }

            return(LeadIndicator.Example_Indicator_SMA_CrossOver_Basic(input));
        }
Esempio n. 2
0
 /// <summary>
 /// Basic indicator example for SMA crossover
 /// </summary>
 public Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic(IDataSeries input)
 {
     return(LeadIndicator.Example_Indicator_SMA_CrossOver_Basic(input));
 }
Esempio n. 3
0
 /// <summary>
 /// Basic indicator example for SMA crossover
 /// </summary>
 public Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic()
 {
     return(LeadIndicator.Example_Indicator_SMA_CrossOver_Basic(InSeries));
 }
Esempio n. 4
0
        protected override void OnCalculate()
        {
            //get the indicator
            Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic = LeadIndicator.Example_Indicator_SMA_CrossOver_Basic();

            //get the value
            double returnvalue = Example_Indicator_SMA_CrossOver_Basic[0];

            //Condition should be drawn on a seperate panel
            this.IsOverlay = false;

            //set the value
            Occurred.Set(returnvalue);
        }
Esempio n. 5
0
        protected override void OnCalculate()
        {
            string uniqueOrderName;

            //get the indicator
            Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic = LeadIndicator.Example_Indicator_SMA_CrossOver_Basic();

            //get the value
            double returnvalue = Example_Indicator_SMA_CrossOver_Basic[0];

            //Entry
            if (returnvalue == 1)
            {
                //define a unique name for the order. in this example the current bars timestamp
                uniqueOrderName = "Long_SMA_CrossOver" + Bars[0].Time.ToString();

                //create the long order with quantity "1" and our unique OrderName
                IOrder _orderenterlong = OpenLong(1, uniqueOrderName);

                //set a stop loss for our order. we set it 1% below the current price
                SetUpStopLoss(_orderenterlong.Name, CalculationMode.Price, Bars[0].Close * 0.99, false);

                //set a target for our order. we set it 1% above the current price
                SetUpProfitTarget(_orderenterlong.Name, CalculationMode.Price, Bars[0].Close * 1.01);
            }
            else if (returnvalue == -1)
            {
                //define a unique name for the order. in this example the current bars timestamp
                uniqueOrderName = "Short_SMA_CrossOver" + Bars[0].Time.ToString();

                //create the short order with quantity "1" and our unique OrderName
                IOrder _orderentershort = OpenShort(1, uniqueOrderName);

                //set a stop loss for our order. we set it 1% above the current price
                SetUpStopLoss(_orderentershort.Name, CalculationMode.Price, Bars[0].Close * 1.01, false);

                //set a target for our order. we set it 1% below the current price
                SetUpProfitTarget(_orderentershort.Name, CalculationMode.Price, Bars[0].Close * 0.99);
            }
        }