SMA Values not loading in BACKTESTING

Created at 29 Apr 2016, 13:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
GoldnOil750's avatar

GoldnOil750

Joined 07.04.2015

SMA Values not loading in BACKTESTING
29 Apr 2016, 13:28


Hi Spotware,

in the backtesting the cBOT is unable to load the SMA values. Although it does load these values on live account.

It is very annoying that after so many years, we still have to see these kind of basic issues.

///S.Khan

 


////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using System.Globalization;
using System.IO;
using System.Threading;
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;


namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

    public class zSMAEMAVALUESBT : Robot
    {

        //// USER INPUT //////////////////////////////////////////////////////////
        [Parameter("<----> Settings <---->")]
        public string temp50 { get; set; }
        // END OF USER INPUT          /////


        //// GLOBAL VARIABLES ///////////////////////////////////////////////////
        // -----------------------------------------------------------
        private MarketSeries Series_1;
        private MarketSeries Series_2;

        private SimpleMovingAverage SMAvg_1;
        private ExponentialMovingAverage EMAvg_1;

        private double Current_SMA_Value;
        private double Current_EMA_Value;

        // -----------------------------------------------------------

        //  END OF GLOBAL VARIABLES   /////


        //// ON START ////////////////////////////////////////////////////////////
        protected override void OnStart()
        {
            Print("");
            Print("cBOT Start Date & Time : " + Server.Time);

            // INITIALIZE SMA AND EMA -------------------------------------------------
            Series_1 = MarketData.GetSeries(TimeFrame.Hour4);
            Series_2 = MarketData.GetSeries(TimeFrame.Hour4);

            SMAvg_1 = Indicators.SimpleMovingAverage(Series_1.Close, 100);
            EMAvg_1 = Indicators.ExponentialMovingAverage(Series_2.Close, 100);
            // ------------------------------------------------------------------------

            Current_SMA_Value = SMAvg_1.Result.Last(0);
            Current_EMA_Value = EMAvg_1.Result.Last(0);

            Print("SMA = " + Current_SMA_Value);
            Print("EMA = " + Current_EMA_Value);

        }
        //END METHOD OnStart()

        //// ON BAR //////////////////////////////////////////////////////////////
        protected override void OnBar()
        {
            // Put your core logic here
        }
        //END METHOD OnBar()

        //// ON TICK //////////////////////////////////////////////////////////////
        protected override void OnTick()
        {
            // Put your core logic here
        }
        //END METHOD OnTick()


        //// ON STOP //////////////////////////////////////////////////////////////
        protected override void OnStop()
        {


            //BLANK LINE
            Print("");
            Print("Method : OnStop() '':   Date & time : " + Server.Time);
        }
        //END METHOD OnStop()

    }
    //END MAIN PUBLIC CLASS
}
//END MAIN cALGO ROBOT

 


@GoldnOil750
Replies

Jiri
29 Apr 2016, 16:06 ( Updated at: 21 Dec 2023, 09:20 )

Works fine on my end. Try lower periods, chart might not have enough data for calculation.


@Jiri

GoldnOil750
29 Apr 2016, 17:08 ( Updated at: 21 Dec 2023, 09:20 )

RE:

nope, my is still the same.  

FxPro, cALGO

18Apr16 to 22Apr16

1min, 1hr, 4hr, Daily.

result is all the same

 

 

tmc. said:

Works fine on my end. Try lower periods, chart might not have enough data for calculation.

 

 


@GoldnOil750

Jiri
29 Apr 2016, 17:33

Even if you change the period to 10, lets say?


@Jiri

GoldnOil750
29 Apr 2016, 21:52

RE:

yes, the SMA worked.  Thank you.     But it is really lousy on the part of cTRADER that one indicator is able to fetch the value, while "SMA", which is the most widely used is not able to fetch the vale in backtesting.  It works ok in LIVE account.

Thanks and for me; day by day it is clear that MT4 has no real threat.

 

tmc. said:

Even if you change the period to 10, lets say?

 


@GoldnOil750