Announcement

Collapse
No announcement yet.

Back test efs for Strategy to not take signals

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Back test efs for Strategy to not take signals

    I am trying to work out the back testing formula code for situation(s) where no signals are to be taken i.e. take no strategy action to go long or short – stay flat – do not do anything.

    The scenario is as follows. I have two moving averages as a band (or envelope) say an eight period MA of the highs and a ten period MA of the lows. When the price bars are inside (between) the MA channels no trades are to be initiated – period. This will be the case irrespective of whatever is exhibited by any indicators.

    How do I code the back test efs to not take any trading action and stay flat?

    I have spent many hours searching through the forum but cannot see anything on this.

    Can someone please help me.

    Robert

  • #2
    Re: Back test efs for Strategy to not take signals

    Robert
    One way is to first create a variable that contains the condition in which you want the trades to be executed eg
    var myCondition = (High > UpperBand || Low < LowerBand);
    Then enclose all your strategy in a conditional statement that checks is myCondition is true eg
    if(myCondition){
    write your strategy here
    }

    The strategy will execute only if the main condition is true ie either the High or the Low of a bar are outside of the bands.
    Hope this helps
    Alex


    Originally posted by charttrader
    I am trying to work out the back testing formula code for situation(s) where no signals are to be taken i.e. take no strategy action to go long or short – stay flat – do not do anything.

    The scenario is as follows. I have two moving averages as a band (or envelope) say an eight period MA of the highs and a ten period MA of the lows. When the price bars are inside (between) the MA channels no trades are to be initiated – period. This will be the case irrespective of whatever is exhibited by any indicators.

    How do I code the back test efs to not take any trading action and stay flat?

    I have spent many hours searching through the forum but cannot see anything on this.

    Can someone please help me.

    Robert

    Comment


    • #3
      Alexis

      Thanks for your quick response. You are a real life saver.

      I will incorporate your advice in my code.

      Best wishes and regards

      Robert

      Comment


      • #4
        Robert
        You are most welcome
        Alex


        Originally posted by charttrader
        Alexis

        Thanks for your quick response. You are a real life saver.

        I will incorporate your advice in my code.

        Best wishes and regards

        Robert

        Comment

        Working...
        X