Announcement

Collapse
No announcement yet.

Issue with DrawText and possibility of ending a script early

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

  • Issue with DrawText and possibility of ending a script early

    hi there,

    ive a couple of issues ive encounter during the making of my studies i would appreciate some help

    1- if you write a code so that in the same candle should appear 2 lines of drawtext, the only that is displayed is the second, it also happens with the line tool

    example -
    drawTextRelative(0,entry + (0.05),"entry-"+entry, Color.green, null, Text.BOLD|Text.CENTER|Text.TOP|Text.ONTOP, null, 12, "l"+getValue("rawtime"));
    drawTextRelative(0,Stop + (0.05),"Stop-"+Stop, Color.green, null, Text.BOLD|Text.CENTER|Text.TOP|Text.ONTOP, null, 12, "l"+getValue("rawtime"));

    2- ive done a backtest so it will from the first candle analyze the remaining ones for a specific setup using the loop instruction.
    now even if i have an option to prevent from the efs to enter the rest of the program i still end up with the time it takes from that first candle to the last one the efs analyzing all the remaining candles,even if they dont enter the time consuming part of the program it still take some time that is being wasted.

    is there an instruction to "send the efs" to the last candle? bypassing the other ones? or to cancel analyzing the remaining of the candles from the first one?.

    thanks

    Paty

  • #2
    ok, first issue i figured out, basic stuff...my bad
    now about the second issue if someone could enlight me i would appreciate, thks

    Comment


    • #3
      Post some basic blueprint code for the 2nd question and I'll try to help. It sounds like you're not quite sure how EFS code gets executed.

      Comment


      • #4
        hi Steve and thanks for the reply...

        well imagine just some basic stuff like getting the high of bar number 5 on the chart

        function main() {
        ti=ti+1;
        if(tc!=1){tc=1;
        ti=getCurrentBarCount();
        }

        if(ti==5){vhigh=high();//this would be the candle where i would have the core of the script, so it will only enter once
        drawTextRelative(0,vhigh,"high-"+vhigh, Color.green, null, Text.BOLD|Text.CENTER|Text.TOP|Text.ONTOP, null, 12, "1");
        //at this point i would like the script to stop processing the remaining Bars until the end of the chart, for a few days of bars test it might not be important, but if you backtest some years with a 1500 stock scan it will make a significant difference just the fact that it processes every single bar even if it doesnt enter the core
        }

        }
        Last edited by Patyforum; 10-04-2012, 11:02 AM.

        Comment


        • #5
          If you want to code up an EFS strictly for backtesting then is there a particular reason why you don't want to use the EFS Strategy Object? That's going to keep track of where you want to go long, short, flat and keep track of the statistics from those entries / exits. You can search the knowledgebase for details.

          This is in the 10.6 product though. The 11.x product doesn't have a built-in backtesting capability yet. It's no big deal to install 10.6 with 11.4. They haven't changed the scripting capabilities except for very minor things like having to use a shift key when you press a left or right mouse button for the script to respond to the mouse clicks.

          Comment


          • #6
            Originally posted by SteveH View Post
            If you want to code up an EFS strictly for backtesting then is there a particular reason why you don't want to use the EFS Strategy Object? That's going to keep track of where you want to go long, short, flat and keep track of the statistics from those entries / exits. You can search the knowledgebase for details.

            This is in the 10.6 product though. The 11.x product doesn't have a built-in backtesting capability yet. It's no big deal to install 10.6 with 11.4. They haven't changed the scripting capabilities except for very minor things like having to use a shift key when you press a left or right mouse button for the script to respond to the mouse clicks.

            Actually i still use 10.6 for most of the stuff specially backtesting.
            The reason are some...the EFS strategy object only works if you are indeed in that candle , if i run a backtest using a loop function to go across the entire bars of the chart i cant use it as it wont accept the if i want to enter in lets say bar 100 because something happen there that triggered it
            example
            if i wanted to enter on the break of the max inside a period of some bars starting from the beginning of the day

            var i=0;
            for (i=0;i<100;i++) {
            if(i==0){max=high(0);min=low(0);//assuming this is the first bar of the day
            }
            else
            {
            if(high(i)>max){max=high(i);entry=1;entryprice=hig h(i);
            Strategy.doLong.....}//as the bar that is being processed outside the loop is not the "i" value the Strategy will not execute properly, cause it will execute and check for the prices of the bar outside the loop(that is the first one) and not on the count (i) inside the loop.
            }

            instead i use my own strategy checking system where i set my entry price, stop and target, if any of those is reached during the loop i simply count it as a gain/loss number/value and then in the end write everything to a file and can analyze it on excel

            so the whole backtest is made on the first bar of the charts, and thats the reason i would need if possible a process to just stop analyzing the rest of the bars for an entry that will not happen cause it will entry the backtest(in this case more a "forwardtest" ) phase only in the first bar.
            Last edited by Patyforum; 10-04-2012, 02:26 PM.

            Comment


            • #7
              If you're doing your own backtest which "starts" on the 1st bar after the historical loading has finished, then is this what you want?

              Code:
              var backtesting = true;
              
              function main()
              {
                if  (isLastBarOnChart() && backtesting == true)
                {
                   // backtest code goes here
                   // loop through all of the historical bars to calc your results
                  
                   backtesting = false;
                }
                else if (isLastBarOnChart())
                {
                   // you're in forward test code here
                }
              }

              Comment

              Working...
              X