Announcement

Collapse
No announcement yet.

Averaging System with multiple entry's and exit's

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

  • #31
    Hi Wayne,

    The markets I trade are very illiquid between the StartTime and EndTime and the charts often print prices which are not truely obtainable, therefore I dont want the strategy to execute between these hours so the "if ((hour(0) * 100) + minute(0) < StartTime || (hour(0) * 100) + minute(0) > EndTime) return;" line is doing its job!

    As for the dayFlag, yeah that makes total sense, although I have included "if (getCurrentBarIndex() == 0) return; " in the code so it will not be working in realtime, so is that still applicable?

    Im sorry, I don't quite follow you regarding the variables. Do they need to be defined in the preMain as "bYLong1 = null" rathwe than "bYLong1 = false?"

    I have experimented with the code, and forced the bYLong1 and bYLong2 variables to be true. I had hoped that this would then lead onto the
    [php]
    if (bYLong1 == true && bYLong2 == true && bYLong3 == false && bYLong4 == false)
    {

    if (high(0)> nYPrice-Sup1)
    {
    nOExitPrice = nYPrice-Sup1;
    Strategy.doSell("Overnight Exit L2 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nOExitPrice);
    drawShape(Shape.DIAMOND, AboveBar2, Color.green);
    bYLong1 = false; bYLong2 = false; bYLong3 = false; bYLong4 = false;
    }
    }

    code in the "Overnight Exit Logic" section being executed (wanting the code to exit a position from the previous day that was held overnight to exit at Yesterdays Open price - Sup1) but this did not happen.

    I then removed the "if (bYLong1 == true && bYLong2 == true && bYLong3 == false && bYLong4 == false)" condition from the above code, but it still did not execute the exit so Im now doubting if the problem lies within these variables.

    I also tried removing the "if (Strategy.isInTrade())" conditions from the overnight exit logic as I thought maybe the EFS strategy object resets itself automatically back to flat at the start of a new day, but that didn't seem to get the code to execute either.

    I hope I am explaining this well enough for you to make sense of it?! Again, thanks in advance for any further help... this one has really got me scratching my head!!

    Daniel

    Comment


    • #32
      Hi Daniel,

      As for the dayFlag, yeah that makes total sense, although I have included "if (getCurrentBarIndex() == 0) return; " in the code so it will not be working in realtime, so is that still applicable?
      Not in that case. If you never intend for it to execute a new trade in real time then you don't need the dayFlag.

      The markets I trade are very illiquid between the StartTime and EndTime and the charts often print prices which are not truely obtainable, therefore I dont want the strategy to execute between these hours so the "if ((hour(0) * 100) + minute(0) < StartTime || (hour(0) * 100) + minute(0) > EndTime) return;" line is doing its job!
      That changes things. I responded to your original request that stated:
      Basically I want all trades to run until they reach an exit signal.
      Which wouldn't happen after the "return;" statement is activated.

      Now, to the meat of the matter.

      Im sorry, I don't quite follow you regarding the variables. Do they need to be defined in the preMain as "bYLong1 = null" rathwe than "bYLong1 = false?"
      Variables declared (variable name is preceded with "var") inside of preMain are not accessible outside of preMain. No, I meant that only declare a variable once as either a global (outside of any function including preMain) or local (within the function that uses it) otherwise a global variable that is also declared locally within a function is never retained through iterations of main(), in other words it is discarded when the function exits/returns. So, in the case of variables within the "day(0)1=day(-1)" block, they are always undefined except during the first bar of the day when the conditionals "day(0)1=day(-1)" and "(Strategy.isInTrade())" are true. You can verify this by adding the following "debugPrintln" lines of code and looking at the output:
      PHP Code:
      ...            if (day(0)!= day(-1)) {
              
              if (
      Strategy.isInTrade()) {
              
                  var 
      bYLong1 bLong1;  //removed the var declaration for all these variables
                  
      var bYLong2 bLong2;  
                  var 
      bYLong3 bLong3;  
                  var 
      bYLong4 bLong4;  
                  var 
      bYShort1 bShort1;  
                  var 
      bYShort2 bShort2;  
                  var 
      bYShort3 bShort3;  
                  var 
      bYShort4 bShort4;
                  var 
      nYPrice open(-22,inv("60"));
               
      debugPrintln("230: "+((hour(0)*100)+minute(0))+"\t"+bYLong1+"\t"+bLong1);//output: "230: 0 true true"
             
      }
          
              
      bLong1 false;  
              
      bLong2 false;  
              
      bLong3 false;  
              
      bLong4 false;  
              
      bShort1 false;  
              
      bShort2 false;  
              
      bShort3 false;  
              
      bShort4 false;  
          }
           
      debugPrintln("242: "+((hour(0)*100)+minute(0))+"\t"+bYLong1+"\t"+bLong1);//ootput: "242: 2    undefined    false"
          
      if((hour(0)*100)+minute(0)< StartTime || (hour(0)*100)+minute(0)> EndTime) return;
      ... 
      The output will be "230: 0 true true" and "242: 2 undefined false"

      To have these variables retain their value through iterations of main (since they are already declared as globals) just remove the var declaration for variables within the "day(0)!=day(-1)" block.

      As a side note, if you add a variable name in a function (like in main or other internal function) without the preceding "var", it will become global instead of local even though it only appears and is assigned a value inside the function.
      Like the variable "foo" in the following script:
      PHP Code:
      function preMain(){
          
      setPriceStudy(true);
          var 
      preM=7;
      }
      function 
      main(){
          
      debugPrintln("preM = "+preM);//outputs: ReferenceError: preM is not defined
          
      foo=3;
          var 
      localFoo=5;
          
      testit();//runs internal function
      }
      function 
      testit(){
          
      debugPrintln("foo = "+foo);//outputs 3
          
      debugPrintln("localFoo = "+localFoo);//outputs: "ReferenceError: localFoo is not defined"

      In an efs script, a global variable is defined outside of any function and is available within all functions in the script. That is different from variables set by the "setGlobalValue()" which are available to any efs (and all their internal functions) running at the time the "setGlobalValue()" is set. Local variables are only available within the function in which they were delcared.

      ...but it still did not execute the exit so Im now doubting if the problem lies within these variables.
      You are right. The issue is that the "Strategy" object only runs one trade at a time, see: http://www.esignalcentral.com/univer...ons/hs1460.htm
      where it states
      If a long position is currently held, calling Strategy.doShort will close the long position and enter a short position.

      If a short position is currently held, calling Strategy.doLong will close the short position and enter a long position.
      Another resource that may be useful is: http://forum.esignal.com/showthread....S-Back-Testing

      As I understand your intent, multiple trades would run at one time. The Strategy object doesn't do that. It either adds to an existing trade or, in the case of entering a trade type opposite to an existing one (there is an open long and a new short is opened), it closes the first trade and enters the opposite type of trade, in effect it just stops and reverses the trade.

      The only way I know of to have multiple trades at one time is to create your own strategy trade management system. It is also necessary to somehow identify each trade with a unique identifier so the script knows to which trade the code refers at any specific time.

      From looking at the code the only way to track a trade is via the Strategy object and drawShape().

      I hope this explains it even if it is not good news.

      Wayne
      Last edited by waynecd; 10-16-2013, 09:52 PM.

      Comment


      • #33
        Hi Daniel,

        I just re-read the whole thread. I have misunderstood your requests miserably. You only want one trade at a time and you want the previous day's limits to be used by open trades carried past the day they were entered and these trades to be closed when price crosses either the carried forward limits or the current day's limits.

        Let me know if that is correct and I will post a modified script.

        Wayne

        Comment


        • #34
          Wayne, you are a Scholar and a Gent!!

          "I just re-read the whole thread. I have misunderstood your requests miserably. You only want one trade at a time and you want the previous day's limits to be used by open trades carried past the day they were entered and these trades to be closed when price crosses either the carried forward limits or the current day's limits."

          Yes that would have been a much better way for me to explain myself in the first place!!!

          Removing the "var" declaration inside the "day(0)!=day(-1)" block has now got the exit code in the "Overnight Logic" section to start executing, which is a massive step forward! Thanks so much for that insight - I had no idea that the "var" altered the variables like that! However, the code seems to be executing immediately after the "StartTime" at whatever price. It does seem to be using the correct choice of exit code [ie if (bYLong == true && bYLong 2 == false)" - so the variables are working] but I don't think it is recognizing the correct exit price signal (so its just executing at market on the fist bar after "StartTime." Does the nYPrice = open(-22,inv("60"));" line look correct to you for referencing Yesterdays open? (The market has a 22 hour trading day.)

          I have also stumbled across another (hopefully much more simple) issue when trying to reference yesterday's settlement price. I am trying to add the option in my code to base the prices from the daily open or the previous days settlement. I have introduced a new boolean function Param in pre Main called "Settlement" and then altered the code near the start of function main to:

          [PHP]

          if((hour(0)*100)+minute(0)==UserTime)
          {
          if(Settlement) { nPrice = close(-1,inv("D"));
          } else nPrice = open(0);
          drawLineRelative( 0, nPrice, LineLen, nPrice+Res1, PS_DOT, 1, Color.maroon, "Up"+LineTag );
          drawLineRelative( 0, nPrice+Res2, LineLen, nPrice+Res2, PS_DOT, 1, Color.green, "Up1"+LineTag );
          drawLineRelative( 0, nPrice+Res3, LineLen, nPrice+Res3, PS_DOT, 1, Color.red, "Up2"+LineTag );
          etc..

          and then:

          [PHP]

          if(plotPrice.indexOf("Open")!=-1) drawTextRelative(PriceOffset, nPrice, nPrice, Color.blue, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP");
          if(plotPrice.indexOf("Res1")!=-1) drawTextRelative(PriceOffset, nPrice+Res1, nPrice+Res1, Color.maroon, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_H");
          if(plotPrice.indexOf("Res2")!=-1) drawTextRelative(PriceOffset, nPrice+Res2, nPrice+Res2, Color.green, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_K");
          if(plotPrice.indexOf("Res3")!=-1) drawTextRelative(PriceOffset, nPrice+Res3, nPrice+Res3, Color.red, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_L");

          The problem is, when Settlement = true, the code will not load on to the chart and gives a EFS warning: Failed to call 'drawTextRelative': parameter # 3 is invalid.
          The error is referring to the first line of the "if(plotPrice.indexOf("Open")!=-1) drawTextR......." code. If I take out the problem line then I get no errors at all and the drawLineRelative function seems to be working fine with the "Settlement." Everything also works fine when Settlement = false.

          I have read a few posts on here about the various options on the eSignal charts to reference the close or the settlements on Daily or longer timeframes. So as well as wondering what is causing the above error, is this the best way to reference yesterdays settlement price in the code??

          Once again Wayne, thanks so much for all your help!!

          Daniel

          Comment


          • #35
            Wayne,

            Having further inspected the "Overnight Logic" code, it is working perfectly sometimes but exiting immediately after "StartTime" as mentioned before at other times.The only difference I can see from looking at the charts is that it hasn't worked properly when only "bLong1" is true, it seems to be working OK when several of the variables are true (ie the strategy has averaged into the position the previous day but I cant see how this would cause the issue?!

            Thanks again

            Comment


            • #36
              Hi Wayne,

              So after looking further into the above issue, I think I have isolated the issue.

              If the strategy takes the first buy signal (bLong1 = true) and then the market moves below the second buy signal but after the EndTime (so the Buy2 trade is not executed,) the strategy appears to think that it is in the second long trade (bLong2 - true) I think. Therefore when carried over night, the strategy then looks for the exit signal as if it were in the second (bLong2) trade which means it will try and exit at a price above the first (bLong1) entry price and therefore appears to exit immediately after the start time (providing this price is above the signal.)

              However, whilst looking at the chart, I noticed one example that is slightly more concerning. The strategy buys at the first buy signal (bLong1 = true) and then the market goes down and touches the second buy price (within the trading hours) but it does not go below it therefore doesn't execute. There are no entry arrows on the chart to confirm this. However, the next day, the Overnight Logic still executes as if it is in the second buy entry (ie bLong2 = true.) This has really thrown me as I thought that the only way the bLong2 variable could have been changed to true was if the second buy signal had been executed.

              I am also getting the messgae "Internal error occurs. Try recalculate report" when I try to bring up a backtest report for this strategy. This only happens on certain charts with the same code so I have no idea what is causing that issue. I asked the development team about this error as well but they do not seem to be able to help.

              Once again, thanks for you help! I hope Ive explained it slightly better this time!!

              Daniel

              Comment


              • #37
                NOTE: I revised a previous post, if you got this before the revision/edit time post below, discard it and use this code.
                try (join the next two posts into one efs):
                PHP Code:
                //http://forum.esignal.com/showthread.php?38847-Averaging-System-with-multiple-entry-s-and-exit-s&p=146750#post146750
                //http://forum.esignal.com/showthread.php?38494-Bands-based-on-Open-Price  
                //http://forum.esignal.com/showthread.php?38847-Averaging-System-with-multiple-entry-s-and-exit-s 
                //I left debug code including the return values in case they are of use to you
                //main issues were:
                // - BARSTATE_ALLBARS was needed to reset the variables since(it seems) the "Strategy" object reloads the script without resetting global variables
                // - since all positions are closed at once, all relevant bLong#, bShort# must be reset to false when the position is closed
                //- you can uncomment the  "else"statements to force one signal per bar 
                //the arrows and triangles are color coded so which arrow is closed by which triangle
                //the return statement allows you to track trade status bar by bar
                //this is how the code actually performs
                debugClear();
                function 
                preMain()  
                {  
                    var 
                aFPArray = new Array();  
                    
                setPriceStudy(true);  
                    
                setCursorLabelName("inTrade",0);  
                    
                setCursorLabelName("isLong",1);  
                    
                setCursorLabelName("isShort",2);
                    
                setCursorLabelName("nPosSize",3);
                    
                setCursorLabelName("bLong1",4);
                    
                setCursorLabelName("bLong2",5);
                    
                setCursorLabelName("bLong3",6);
                    
                setCursorLabelName("bLong4",7);
                    
                setCursorLabelName("bShort1",8);
                    
                setCursorLabelName("bShort2",9);
                    
                setCursorLabelName("bShort3",10);
                    
                setCursorLabelName("bShort4",11);
                    
                setCursorLabelName("TradeBarPosition",12);
                    
                setCursorLabelName("dayCtr",13);
                    
                    var 
                x=0;  
                    
                aFPArray[x] = new FunctionParameter("UserTime"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Start Time For Open (2300)");  
                        
                setLowerLimit(0);          
                        
                setUpperLimit(2400);          
                        
                setDefault(100);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("StartTime"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Start Time For Trading");  
                        
                setLowerLimit(0);          
                        
                setUpperLimit(2400);          
                        
                setDefault(700);  
                    }
                    
                aFPArray[x] = new FunctionParameter("EndTime"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("End Time For Trading");  
                        
                setLowerLimit(0);          
                        
                setUpperLimit(2400);          
                        
                setDefault(2100);  
                    }
                    
                aFPArray[x] = new FunctionParameter("LineLen"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Line Length");  
                        
                setLowerLimit(1);          
                        
                setDefault(200);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Res1"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Res1");  
                        
                setLowerLimit(0);          
                        
                setDefault(.6);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Res2"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Res2");  
                        
                setLowerLimit(0);          
                        
                setDefault(.9);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Res3"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Res3");  
                        
                setLowerLimit(0);          
                        
                setDefault(1.5);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Res4"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Res4");  
                        
                setLowerLimit(0);          
                        
                setDefault(3.25);  
                    }  
                  
                aFPArray[x] = new FunctionParameter("Sup1"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Sup1");  
                        
                setLowerLimit(0);          
                        
                setDefault(.6);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Sup2"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Sup2");  
                        
                setLowerLimit(0);          
                        
                setDefault(.9);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Sup3"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Sup3");  
                        
                setLowerLimit(0);          
                        
                setDefault(1.5);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("Sup4"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Sup4");  
                        
                setLowerLimit(0);          
                        
                setDefault(3.25);  
                    }
                    
                aFPArray[x] = new FunctionParameter("TodayOnly"FunctionParameter.BOOLEAN);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setDefault(true);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("PriceOffset"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Price Offset");  
                        
                setLowerLimit(0);          
                        
                setDefault(3);  
                    }  
                    
                aFPArray[x] = new FunctionParameter("TrdSz1"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("TrdSz1");  
                        
                setLowerLimit(0);          
                        
                setDefault(2);  
                    } 
                aFPArray[x] = new FunctionParameter("TrdSz2"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("TrdSz2");  
                        
                setLowerLimit(0);          
                        
                setDefault(1);  
                    } 
                aFPArray[x] = new FunctionParameter("TrdSz3"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("TrdSz3");  
                        
                setLowerLimit(0);          
                        
                setDefault(1);  
                    } 
                aFPArray[x] = new FunctionParameter("TrdSz4"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("TrdSz4");  
                        
                setLowerLimit(0);          
                        
                setDefault(2);  
                    } 
                aFPArray[x] = new FunctionParameter("MaxClip"FunctionParameter.NUMBER);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("MaxClip");  
                        
                setLowerLimit(0);          
                        
                setDefault(10);  
                    }
                    
                aFPArray[x] = new FunctionParameter("plotPrice"FunctionParameter.STRING);  
                    
                with(aFPArray[x++]) 
                    {  
                        
                setName("Plot Price At");  
                        
                addOption("Open Only");  
                        
                addOption("Open & Res1");  
                        
                addOption("Res1 & Res2 & Res3");  
                        
                addOption("Res1 & Res2 & Res3 & Res4")  
                        
                setDefault("Open & Res1 & Res2 & Res3 & Res4 & Sup1 & Sup2 & Sup3 & Sup4");  
                    }  
                }  

                    var 
                bInit false;
                    
                //new days values
                    
                var bLong1 false;  
                    var 
                bLong2 false;  
                    var 
                bLong3 false;  
                    var 
                bLong4 false;  
                    var 
                bShort1 false;  
                    var 
                bShort2 false;  
                    var 
                bShort3 false;  
                    var 
                bShort4 false;  
                    var 
                nPrice null;  
                    
                //yesterdays values
                    
                var nYPrice null;
                    
                    var 
                nPosSize null;
                    var 
                barPosition=null;//added to track bar count at "UserTime"
                    
                var nExitPrice=null;//added
                    
                var nEntryPrice=null;//added
                    
                var TradeBarPosition null;//added
                    
                var YesterdaysTrade=false;//added
                    
                var dayCtr=0;//added 
                Last edited by waynecd; 10-17-2013, 09:46 AM.

                Comment


                • #38
                  PHP Code:
                  function main(UserTime,StartTime,EndTime,LineLen,Res1,Res2,Res3,Res4,Sup1,Sup2,Sup3,Sup4,TodayOnly,plotPrice,PriceOffset,TrdSz1,TrdSz2,TrdSz3,TrdSz4,MaxClip)  
                  {  
                      if(
                  getBarState()==BARSTATE_ALLBARS){
                          
                  bLong1 false;  
                          
                  bLong2 false;  
                          
                  bLong3 false;  
                          
                  bLong4 false;  
                          
                  bShort1 false;  
                          
                  bShort2 false;  
                          
                  bShort3 false;  
                          
                  bShort4 false;  
                          
                  nPrice null;  
                          
                  //yesterdays values
                          
                  nYPrice null;
                      
                          
                  nPosSize null;
                          
                  barPosition=null;//added to track bar count at "UserTime"
                          
                  nExitPrice=null;//added
                          
                  nEntryPrice=null;//added
                          
                  dayCtr=0;//added
                      
                  }
                      var 
                  xOpen  nullLineTag null//modified 
                      
                  if(TodayOnlyLineTag 105;  
                      else 
                  LineTag gID();  
                      if(
                  isMonthly() || isWeekly() || isDaily()) return;
                      
                      if((
                  hour(0)*100)+minute(0)==UserTime
                      { 
                          
                  nPrice open(0);
                          
                  barPosition    =getCurrentBarCount();
                          
                  drawLineRelative0open(0)+Res1LineLenopen(0)+Res1PS_DOT1Color.maroon"Up"+LineTag );  
                          
                  drawLineRelative0open(0)+Res2LineLenopen(0)+Res2PS_DOT1Color.green"Up1"+LineTag );  
                          
                  drawLineRelative0open(0)+Res3LineLenopen(0)+Res3PS_DOT1Color.red"Up2"+LineTag );  
                          
                  drawLineRelative0open(0)+Res4LineLenopen(0)+Res4PS_DOT2Color.red"Up3"+LineTag );  
                          
                  drawLineRelative0open(0)-Sup1LineLenopen(0)-Sup1PS_DOT1Color.maroon"Dwn1"+LineTag );  
                          
                  drawLineRelative0open(0)-Sup2LineLenopen(0)-Sup2PS_DOT1Color.green"Dwn2"+LineTag );  
                          
                  drawLineRelative0open(0)-Sup3LineLenopen(0)-Sup3PS_DOT1Color.red"Dwn3"+LineTag );  
                          
                  drawLineRelative0open(0)-Sup4LineLenopen(0)-Sup4PS_DOT2Color.red"Dwn4"+LineTag );  
                          
                  drawLineRelative0open(0), LineLenopen(0), PS_SOLID1Color.blue"OpenMid"+LineTag );   
                            
                      }

                      var 
                  nPosSize Strategy.getPositionSize();

                      if (
                  day(0)!= day(-1)) 
                      {
                          
                  dayCtr++;
                          if(
                  dayCtr>0)
                          {
                              if (
                  Strategy.isInTrade()) 
                              {
                                  
                  nYPrice open(TradeBarPosition getCurrentBarCount());//more accurate and spans over future days not just yesterday
                                  
                  YesterdaysTrade=true;
                              }else{
                                  
                  nYPrice=null;
                                  
                  YesterdaysTrade=false;
                              }
                          }
                      }
                      if(
                  dayCtr>&& (hour(0)*100)+minute(0)>= StartTime && (hour(0)*100)+minute(0)<= EndTime)
                      { 
                  //dayCtr=0 exclusion required since there are no levels on the first day
                      
                          
                  setBarBgColor(Color.RGB(230,255,207));//shades background during trading hours, visual aid only

                          
                  if (isLastBarOnChart()) return;   
                           
                      
                  // Entry Short Signals   

                      
                  if (nPosSize > -MaxClip && bShort1 == false && bShort2 == false && bShort3 == false && bShort4 == false && bLong1 == false && bLong2 == false && bLong3 == false && bLong4 == false)   
                      {   
                  //debugPrintln("227: "+(barPosition - getCurrentBarCount()));
                          
                  if (high(0)> nPrice+Res1)   
                          {   
                              
                  TradeBarPosition barPosition;//tracks the open at the time of the first trigger
                              
                  nEntryPrice nPrice+Res1;   
                              
                  Strategy.doShort("Entry Short1 Signal"Strategy.LIMITStrategy.THISBARTrdSz1nEntryPrice);   
                              
                  drawShape(Shape.DOWNARROWAboveBar2Color.red,"S1E"+LineTag);   
                              
                  bShort1 true
                          }  
                      }
                  //else  
                      
                  if (nPosSize > -MaxClip && bShort1 == true && bShort2 == false && bShort3 == false && bShort4 == false && bLong1 == false && bLong2 == false && bLong3 == false && bLong4 == false)   
                      {     
                  //debugPrintln("237: "+(barPosition - getCurrentBarCount())); 
                          
                  if (high(0)> nPrice+Res2)   
                          {   
                              
                  nEntryPrice nPrice+Res2;   
                              
                  Strategy.doShort("Entry Short2 Signal"Strategy.LIMITStrategy.THISBARTrdSz2nEntryPrice);   
                              
                  drawShape(Shape.DOWNARROWAboveBar2Color.magenta,"S2E"+LineTag);   
                              
                  bShort2 true;   
                          }   
                      }
                  //else   
                      
                  if (nPosSize > -MaxClip && bShort1 == true && bShort2 == true && bShort3 == false && bShort4 == false && bLong1 == false && bLong2 == false && bLong3 == false && bLong4 == false)   
                      {      
                  //debugPrintln("247: "+(barPosition - getCurrentBarCount()));
                          
                  if (high(0)> nPrice+Res3)   
                          {   
                              
                  nEntryPrice nPrice+Res3;   
                              
                  Strategy.doShort("Entry Short3 Signal"Strategy.LIMITStrategy.THISBARTrdSz3nEntryPrice);   
                              
                  drawShape(Shape.DOWNARROWAboveBar2Color.RGB(255,155,0),"S3E"+LineTag);   //orange
                              
                  bShort3 true;   
                          }   
                      }
                  //else   
                      
                  if (nPosSize > -MaxClip && bShort1 == true && bShort2 == true && bShort3 == true && bShort4 == false && bLong1 == false && bLong2 == false && bLong3 == false && bLong4 == false)   
                      {     
                  //debugPrintln("257: "+(barPosition - getCurrentBarCount())); 
                          
                  if (high(0)> nPrice+Res4)   
                          {   
                              
                  nEntryPrice nPrice+Res4;   
                              
                  Strategy.doShort("Entry Short4 Signal"Strategy.LIMITStrategy.THISBARTrdSz4nEntryPrice);   
                              
                  drawShape(Shape.DOWNARROWAboveBar2Color.purple,"S4E"+LineTag);   
                              
                  bShort4 true;      
                          }   
                      }  
                      
                  //Entry Long Signals   
                        
                      
                  if (nPosSize MaxClip && bShort1 == false && bShort2 == false && bShort3 == false && bShort4 == false && bLong1 == false && bLong2 == false && bLong3 == false && bLong4 == false)   
                      {      
                  //debugPrintln("269: "+(barPosition - getCurrentBarCount()));
                          
                  if (low(0)< nPrice-Sup1)   
                          {   
                              
                  TradeBarPosition barPosition;//tracks the open at the time of the first trigger
                              
                  nEntryPrice nPrice-Sup1;   
                              
                  Strategy.doLong("Entry Long1 Signal"Strategy.LIMITStrategy.THISBARTrdSz1nEntryPrice);   
                              
                  drawShape(Shape.UPARROWBelowBar2Color.green,"L1E"+LineTag);   
                              
                  bLong1 true
                          }   
                      }
                  //else   
                      
                  if (nPosSize MaxClip && bShort1 == false && bShort2 == false && bShort3 == false && bShort4 == false && bLong1 == true && bLong2 == false && bLong3 == false && bLong4 == false)   
                      {     
                  //debugPrintln("279: "+(barPosition - getCurrentBarCount())); 
                          
                  if (low(0)< nPrice-Sup2)   
                          {   
                              
                  nEntryPrice nPrice-Sup2;   
                              
                  Strategy.doLong("Entry Long2 Signal"Strategy.LIMITStrategy.THISBARTrdSz2nEntryPrice);   
                              
                  drawShape(Shape.UPARROWBelowBar2Color.blue,"L2E"+LineTag);   
                              
                  bLong2 true;   
                          }   
                      }
                  //else   
                      
                  if (nPosSize MaxClip && bShort1 == false && bShort2 == false && bShort3 == false && bShort4 == false && bLong1 == true && bLong2 == true && bLong3 == false && bLong4 == false)   
                      {      
                  //debugPrintln("289: "+(barPosition - getCurrentBarCount()));
                          
                  if (low(0)< nPrice-Sup3)   
                          {   
                              
                  nEntryPrice nPrice-Sup3;   
                              
                  Strategy.doLong("Entry Long3 Signal"Strategy.LIMITStrategy.THISBARTrdSz3nEntryPrice);   
                              
                  drawShape(Shape.UPARROWBelowBar2Color.lime,"L3E"+LineTag);   
                              
                  bLong3 true;   
                          }   
                      }
                  //else   
                      
                  if (nPosSize MaxClip && bShort1 == false && bShort2 == false && bShort3 == false && bShort4 == false && bLong1 == true && bLong2 == true && bLong3 == true && bLong4 == false)   
                      {      
                  //debugPrintln("299: "+(barPosition - getCurrentBarCount()));
                          
                  if (low(0)< nPrice-Sup4)   
                          {   
                              
                  nEntryPrice nPrice-Sup4;   
                              
                  Strategy.doLong("Entry Long4 Signal"Strategy.LIMITStrategy.THISBARTrdSz4nEntryPrice);   
                              
                  drawShape(Shape.UPARROWBelowBar2Color.cyan,"L4E"+LineTag);   
                              
                  bLong4 true;   
                          }   
                      }  
                         
                      
                  //Exit Signals   
                      
                  if (Strategy.isInTrade() == true)   
                      {   
                         
                          if (
                  Strategy.isShort() == true)   
                          {   
                                 
                              if (
                  bShort1 == true && bShort2 == false && bShort3 == false && bShort4 == false)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && low(0)< nYPrice) || low(0)< nPrice)   
                                  {   
                                      
                  nExitPrice nPrice;   
                                      
                  Strategy.doCover("Cover Short1 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDBelowBar2Color.reg,"S1Ex"+LineTag); 
                                      
                  bShort1 false;  
                                      
                  bShort2 false;  
                                      
                  bShort3 false;  
                                      
                  bShort4 false;  
                                  }   
                              }
                  //else   
                              
                  if (bShort1 == true && bShort2 == true && bShort3 == false && bShort4 == false)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && low(0)< nYPrice+Res1) || low(0)< nPrice+Res1)   
                                  {   
                                      
                  nExitPrice nPrice+Res1;   
                                      
                  Strategy.doCover("Cover Short2 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDBelowBar2Color.magenta,"S2Ex"+LineTag);  
                                      
                  bShort1 false;  
                                      
                  bShort2 false;  
                                      
                  bShort3 false;  
                                      
                  bShort4 false;  
                                  }   
                              }
                  //else   
                              
                  if (bShort1 == true && bShort2 == true && bShort3 == true && bShort4 == false)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && low(0)< nYPrice+Res2) || low(0)< nPrice+Res2)   
                                  {   
                                      
                  nExitPrice nPrice+Res2;   
                                      
                  Strategy.doCover("Cover Short3 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDBelowBar2Color.RGB(255,155,0),"S3Ex"+LineTag);  
                                      
                  bShort1 false;  
                                      
                  bShort2 false;  
                                      
                  bShort3 false;  
                                      
                  bShort4 false;  
                                  }   
                              }
                  //else   
                              
                  if (bShort1 == true && bShort2 == true && bShort3 == true && bShort4 == true)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && low(0)< nYPrice+Res3) || low(0)< nPrice+Res3)   
                                  {   
                                      
                  nExitPrice nPrice+Res3;   
                                      
                  Strategy.doCover("Cover Short4 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDBelowBar2Color.purple,"S4Ex"+LineTag);   
                                      
                  bShort1 false;  
                                      
                  bShort2 false;  
                                      
                  bShort3 false;  
                                      
                  bShort4 false;  
                                  }   
                              }   
                          }  else if (
                  Strategy.isLong() == true)   
                          {   
                                 
                              if (
                  bLong1 == true && bLong2 == false && bLong3 == false && bLong4 == false)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && high(0)> nYPrice) || high(0)> nPrice)   
                                  {   
                                      
                  nExitPrice nPrice;   
                                      
                  Strategy.doSell("Sell Long1 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDAboveBar2Color.green,"L1Ex"+LineTag);  
                                      
                  bLong1 false;   
                                      
                  bLong2 false;   
                                      
                  bLong3 false;   
                                      
                  bLong4 false;   
                                  }   
                              }
                  //else   
                              
                  if (bLong1 == true && bLong2 == true && bLong3 == false && bLong4 == false)   
                              {   
                                  if((
                  YesterdaysTrade==true && high(0)> nYPrice-Sup1) || high(0)> nPrice-Sup1)   
                                  {   
                                      
                  nExitPrice nPrice-Sup1;   
                                      
                  Strategy.doSell("Sell Long2 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDAboveBar2Color.blue,"L2Ex"+LineTag);  
                                      
                  bLong1 false;   
                                      
                  bLong2 false;   
                                      
                  bLong3 false;   
                                      
                  bLong4 false;   
                                  }   
                              }
                  //else   
                              
                  if (bLong1 == true && bLong2 == true && bLong3 == true && bLong4 == false)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && high(0)> nYPrice-Sup2) || high(0)> nPrice-Sup2)   
                                  {   
                                      
                  nExitPrice nPrice-Sup2;   
                                      
                  Strategy.doSell("Sell Long3 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDAboveBar2Color.lime,"L3Ex"+LineTag);  
                                      
                  bLong1 false;   
                                      
                  bLong2 false;   
                                      
                  bLong3 false;   
                                      
                  bLong4 false;   
                                  }   
                              }
                  //else   
                              
                  if (bLong1 == true && bLong2 == true && bLong3 == true && bLong4 == true)   
                              {   
                                     
                                  if((
                  YesterdaysTrade==true && high(0)> nYPrice-Sup3) || high(0)> nPrice-Sup3)   
                                  {   
                                      
                  nExitPrice nPrice-Sup3;   
                                      
                  Strategy.doSell("Sell Long4 Signal"Strategy.LIMITStrategy.THISBARStrategy.ALLnExitPrice);   
                                      
                  drawShape(Shape.DIAMONDAboveBar2Color.cyan,"L4Ex"+LineTag);  
                                      
                  bLong1 false;   
                                      
                  bLong2 false;   
                                      
                  bLong3 false;   
                                      
                  bLong4 false;   
                                  }   
                              }   
                          }   
                      }  

                      if(
                  nPrice!=null){
                          if(
                  plotPrice.indexOf("Open")!=-1drawTextRelative(PriceOffsetnPricenPriceColor.bluenullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP");   
                          if(
                  plotPrice.indexOf("Res1")!=-1drawTextRelative(PriceOffsetnPrice+Res1nPrice+Res1Color.maroonnullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_H");   
                          if(
                  plotPrice.indexOf("Res2")!=-1drawTextRelative(PriceOffsetnPrice+Res2nPrice+Res2Color.greennullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_K");   
                          if(
                  plotPrice.indexOf("Res3")!=-1drawTextRelative(PriceOffsetnPrice+Res3nPrice+Res3Color.rednullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_L");   
                          if(
                  plotPrice.indexOf("Res4")!=-1drawTextRelative(PriceOffsetnPrice+Res4nPrice+Res4Color.rednullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_M");   
                          if(
                  plotPrice.indexOf("Sup1")!=-1drawTextRelative(PriceOffsetnPrice-Sup1nPrice-Sup1Color.maroonnullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_N");   
                          if(
                  plotPrice.indexOf("Sup2")!=-1drawTextRelative(PriceOffsetnPrice-Sup2nPrice-Sup2Color.greennullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_O");   
                          if(
                  plotPrice.indexOf("Sup3")!=-1drawTextRelative(PriceOffsetnPrice-Sup3nPrice-Sup3Color.rednullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_P");   
                          if(
                  plotPrice.indexOf("Sup4")!=-1drawTextRelative(PriceOffsetnPrice-Sup4nPrice-Sup4Color.rednullText.BOLD Text.LEFT Text.VCENTERnull10"TimeP_Q");   
                      }
                      }
                      return [
                  Strategy.isInTrade(), Strategy.isLong(),Strategy.isShort(),nPosSize+"",bLong1 ,bLong2,bLong3,bLong4,bShort1,bShort2,bShort3,bShort4,TradeBarPosition+"",dayCtr+""];
                             
                  }   
                  var 
                  grID 0;   
                  function 
                  gID()   
                  {   
                      
                  grID ++;   
                      return( 
                  grID );   

                  Join the above two posts into one efs.

                  Wayne
                  Last edited by waynecd; 10-17-2013, 09:55 AM.

                  Comment


                  • #39
                    I should note that I programmed it conceptually with the hope that you might glean some useful techniques, etc.
                    I leave the detailed testing, including signal accuracy, to you.
                    If you compare troublesome code blocks in your last script against the working sample above (try replacing code components in my code with buggy code blocks in yours) to see the effect. I think most of the questions in your last couple of posts will be answered.

                    One thing I can't explain is the need for the BARSTATE_ALLBARS conditional to reset the variables during coding, it seems the efs somehow iterated a couple of times and returned to the beginning with useless data that stoped execution. If I commented out the "dayCtr" within BARSTATE_ALLBARS the count started off at 2 not 0. Later I ran the code with the BARSTATE_ALLBARS commented out and it worked fine, like I said, I have no explanation other than the above or that somehow some global values were retained through manual reloads of the efs. Try commenting out the whole BARSTATE_ALLBARS block on your end, at least on my end, once I shut down eSignal and restarted it, it was no longer needed.

                    At the top of the script I commented my major changes, you can disregard the first commented issue if you concur with me that BARSTATE_ALLBARS isn't needed.
                    Ignore the last comment in that list of changes, just hubris on my part, only thorough testing against your concept can justify the comment "this is how the code actually performs"

                    Wayne
                    Last edited by waynecd; 10-17-2013, 05:52 PM.

                    Comment


                    • #40
                      Hi Wayne,
                      although this seems a simple add in, for some reason i cant get it to work.
                      I want to be able to replace the open with the previous days settlement for a comparison when using the study on a futures spread. I have managed to get this working, however by using the close -1,inv("D"), esignal returns the 'last' price of the exchange quoted spread for the previous day, not the settlement price. If i enter the spread as the sum of its two individual legs (i.e one leg minus the other) it returns the correct settlement price. Support are aware of this bug and a fix will come in a new release. To get the correct settlement price I want to be able to use sym() function to reference to two individual instruments of the spread x & y , to return open price as z where z = x - y

                      heres what I have come up with but it will not return the previous days settlement price.
                      [PHP]

                      function preMain(){

                      setStudyTitle("Overlay Test");

                      var x=null;
                      var y=null;
                      var z=null;
                      }

                      function main(){


                      if (day(0)!= day(-1)) {

                      x = close((-1,inv("D")),sym("SYMBOL1"));
                      y = close((-1,inv("D")),sym("SYMBOL2"));
                      }

                      z = x - y;

                      return z;

                      }

                      any hints would be great

                      thanks

                      Comment


                      • #41
                        Hi,

                        Read my previous post about variables, specifically within preMain(), also review the glossary at this link for functions, their use, and their syntax as you code. It will answer many if not most of your questions.

                        Issues with the last code you posted include defining variables locally within preMain instead of globally and incorrect use of the inv() and sym() functions. For one thing, use one or the other as a parameter in a function, not both. In your case you want to use sym() properly formatted.

                        Wayne
                        Last edited by waynecd; 10-23-2013, 02:48 AM.

                        Comment


                        • #42
                          Hi Wayne,

                          Yes, thanks for pointing me in the right direction there! All sorted now!!

                          I still have one remaining problem though. I am still getting the messgae "Internal error occurs. Try recalculate report" when I try to bring up a backtest report for this strategy.

                          I have isolated the error to when the "Overnight Logic" if active, but I have no clue what could be causing the issue, as the buy and sell signals appear to be working correctly on the charts, and there is no other error message other than this one in the back test report!!

                          Thanks again

                          Daniel

                          Comment


                          • #43
                            Hi Daniel,

                            The short answer is I don't know. The code I posted above works on my end (unless I didn't run it when the "overnight logic" is active).

                            If you like, post your code and specify during what hours you run it and with what instruments. I'll take a look.
                            A caveat though, I don't know the internals of the backtest report process so if anyone else has input, please feel free.

                            Wayne
                            Last edited by waynecd; 10-25-2013, 11:54 AM.

                            Comment


                            • #44
                              Hi Wayne, Yeah that would be great if you could run the code your end and see if you get the same issue!? I will post the most recent code below. One of the scenarios in which Im getting this problem is on the ES Z3 5min chart displaying data from at least 2nd Oct. In the "Edit Chart" section I have included a "Overnight Logic" tick box. If that is unchecked, the backtest report appears with no problems. However when the tick box is checked, although the buy and sell signals appear correctly on the chart, I get the error message when trying to display a back test report. Interestingly if I open a new chart (which hasnt loaded much data from previous days at all) I can get the back test to give some results with the overnight logic tick box checked.

                              Many thanks in advance

                              Daniel

                              Comment


                              • #45
                                PHP Code:
                                //http://forum.esignal.com/showthread.php?38494-Bands-based-on-Open-Price  
                                //http://forum.esignal.com/showthread.php?38847-Averaging-System-with-multiple-entry-s-and-exit-s 
                                function preMain()  
                                {  
                                    var 
                                aFPArray = new Array();  
                                    
                                setPriceStudy(true);  
                                    
                                setCursorLabelName("TodayOpen");  

                                    var 
                                x=0;  
                                    
                                aFPArray[x] = new FunctionParameter("UserTime"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Start Time For Open");  
                                        
                                setLowerLimit(0);          
                                        
                                setUpperLimit(2400);          
                                        
                                setDefault(100);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("StartTime"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Start Time For Trading");  
                                        
                                setLowerLimit(0);          
                                        
                                setUpperLimit(2400);          
                                        
                                setDefault(700);  
                                    }
                                    
                                aFPArray[x] = new FunctionParameter("EndTime"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("End Time For Trading");  
                                        
                                setLowerLimit(0);          
                                        
                                setUpperLimit(2400);          
                                        
                                setDefault(1930);  
                                    }
                                    
                                aFPArray[x] = new FunctionParameter("OvernightLogic"FunctionParameter.BOOLEAN);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setDefault(false);  
                                    }
                                    
                                aFPArray[x] = new FunctionParameter("LineLen"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Line Length");  
                                        
                                setLowerLimit(1);          
                                        
                                setDefault(200);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("Lv1"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Level");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(3);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("Lv2"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Level 2");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(8);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("Lv3"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Level 3");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(14);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("Lv4"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Level 4");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(18);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("Stop"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Stop Loss");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(.3);  
                                    }
                                    
                                aFPArray[x] = new FunctionParameter("CloseAllTime"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Close All Open Trades");  
                                        
                                setLowerLimit(0);          
                                        
                                setUpperLimit(2400);          
                                        
                                setDefault(1945);  
                                    }
                                    
                                aFPArray[x] = new FunctionParameter("TodayOnly"FunctionParameter.BOOLEAN);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setDefault(true);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("PriceOffset"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Price Offset");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(3);  
                                    }  
                                    
                                aFPArray[x] = new FunctionParameter("TrdSz1"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Trade Size 1");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(2);  
                                    } 
                                aFPArray[x] = new FunctionParameter("TrdSz2"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Trade Size 2");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(1);  
                                    } 
                                aFPArray[x] = new FunctionParameter("TrdSz3"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Trade Size 3");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(1);  
                                    } 
                                aFPArray[x] = new FunctionParameter("TrdSz4"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Trade Size 4");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(2);  
                                    } 
                                aFPArray[x] = new FunctionParameter("MaxClip"FunctionParameter.NUMBER);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("MaxClip");  
                                        
                                setLowerLimit(0);          
                                        
                                setDefault(10);  
                                    }
                                    
                                aFPArray[x] = new FunctionParameter("plotPrice"FunctionParameter.STRING);  
                                    
                                with(aFPArray[x++]) 
                                    {  
                                        
                                setName("Plot Price At");  
                                        
                                addOption("Open Only");  
                                        
                                addOption("Open & Res1 & Res2 & Res3 & Sup1 & Sup2 & Sup3");  
                                        
                                addOption("Open & Res1 & Res2 & Res3 & Res4 & Sup1 & Sup2 & Sup3 & Sup4")  
                                        
                                setDefault("Open & Res1 & Res2 & Res3 & Res4 & Sup1 & Sup2 & Sup3 & Sup4");  
                                    }  
                                }  

                                    var 
                                bInit null;

                                    var 
                                bLong1 null;  
                                    var 
                                bLong2 null;  
                                    var 
                                bLong3 null;  
                                    var 
                                bLong4 null;  
                                    var 
                                bShort1 null;  
                                    var 
                                bShort2 null;  
                                    var 
                                bShort3 null;  
                                    var 
                                bShort4 null;  
                                    var 
                                nPrice 0;  

                                    var 
                                nYPrice 0;
                                    
                                    var 
                                bYLong1 null;
                                    var 
                                bYLong2 null;
                                    var 
                                bYLong3 null;
                                    var 
                                bYLong4 null;
                                    var 
                                bYShort1 null;
                                    var 
                                bYShort2 null;
                                    var 
                                bYShort3 null;
                                    var 
                                bYShort4 null;
                                    
                                    var 
                                nPosSize null;
                                    
                                    var 
                                nStop null;
                                    var 
                                bExitFlag null;
                                    
                                    var 
                                nTime null;
                                    var 
                                nBarIndex null;
                                    var 
                                nBar1 null
                                Last edited by ferret; 10-28-2013, 10:51 AM.

                                Comment

                                Working...
                                X