Announcement

Collapse
No announcement yet.

back testing

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

  • #16
    Jay:

    It works great.....now if someone can just help with the time I'm good to go.

    Lastly, sometimes I trade ZN (TY) and they count in 1/64th or 1/32nd....is there an easy way to get the report to reflex points versus $?

    Bruce

    Comment


    • #17
      Here is a snippet of code from something recent I did re time intervals, sTime=start time, eTime=end time

      This will check to see if the current BAR time, not clock time, is after the start and before the close.

      if(getBarState()==BARSTATE_NEWBAR){
      getH =getValue("Hour");
      getMin=getValue("Minute");
      BarTime=getH*100+getMin;
      }

      if(BarTime > sTime && BarTime < eTime){
      doSometin'
      }

      Comment


      • #18
        David:

        Would this be correct?


        if(getBarState()==BARSTATE_NEWBAR){
        getH =getValue("0500");
        getMin=getValue("0030");
        BarTime=getH*100+getMin;
        }

        if(BarTime > sTime && BarTime < eTime){
        doSometin'
        }

        Whould it also go in the main section?

        Bruce

        Comment


        • #19
          Bruce

          You are correct this goes in main()

          getValue() has a number of fields hat go inside the (), hour is one of them, along with high, close, etc. You need to find Chris K's EFS help file for all the definitions of all the command available.

          getH is a variable assigned the value of getValue("Hour");

          If you are going to use getH later in the program, I would recommend a var getH before the preMain() section. This way the efs will remember the value from tick to tick (iteratio to iteration)

          Kapesh?

          Comment


          • #20


            is the efs help file every one should have

            Comment


            • #21
              To be honest I'm way over my head.

              I just want the study to only work between 0520 and 1315.....

              Bruce

              Comment


              • #22
                if(getBarState()==BARSTATE_NEWBAR){
                getH =getValue("Hour");
                getMin=getValue("Minute");
                BarTime=getH*100+getMin;
                }

                if(BarTime > 520 && BarTime < 1315){
                doSometin'
                }

                will do something from 520 to 1315.

                What do you want to do?

                Comment


                • #23
                  David:

                  Here is the study..... should this go in front of it?
                  Attached Files

                  Comment


                  • #24
                    try this
                    Attached Files

                    Comment


                    • #25
                      I loaded the file and it says there is an error in it....any suggestions?

                      Bruce

                      Comment


                      • #26
                        there was a variable undefined, sorry.

                        Comment


                        • #27
                          forgot the attachment sorry
                          Attached Files

                          Comment


                          • #28
                            David:

                            Thanks again but could I ask for one more thing?

                            Can we get it to close all open trades at 1230?

                            Bruce

                            P.S. it looks like they are being carried over

                            Comment


                            • #29
                              I dont know the code to close a trade if it is open, but

                              if (nSAR <= low() && vTrade != "Long") {
                              Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR);
                              drawTextRelative(1, low(1), "B", Color.black, Color.yellow, Text.FRAME | Text.ONTOP| Text.CENTER | Text.BOLD, null, 12);
                              vTrade = "Long";


                              if(BarTime>1230) insert close instruction here

                              Comment


                              • #30
                                David:

                                Thanks again for your help.

                                Hopefully, someone will know how to exit an exiting position based upon time.

                                Bruce

                                Comment

                                Working...
                                X