Announcement

Collapse
No announcement yet.

Default lot size

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

  • Default lot size

    Hi on some days I want to modify my default lot size thats passed from the back tester config menu. This is what I did and I can not get it to work.

    var size = Strategy.getDefaultLotSize()

    It always retruns a value of 100 no matter what.

    I have it set to 5 in my menu (futures). Not sure where its getting this value.
    Any ideas?
    thx

    Geoff

  • #2
    Geoff
    Strategy.getDefaultLotSize() uses the value set in the Back Testing window (see enclosed image).



    To use a different lot size you can either set that in the Back Testing window or add a variable in your code which you then use as the optional nLotSize parameter in the various Strategy methods (ie doLong(), do Short(), doCover(), etc). Enclosed is a basic example of this.
    For more detailed information and examples you may want to reveiew the Back Testing Tutorial1: Introduction to the Strtagey Object which is available in the EFS KnowledgeBase
    Alex

    PHP Code:
    function preMain(){
        
    setPriceStudy(true);
        
    setCursorLabelName("MA");
    }
     
    var 
    Study null;
     
    function 
    main(){
     
        if(
    Study==nullStudy sma(10);
        
        var 
    myLotSize 5;
        
        if(!
    Strategy.isLong()){
            if(
    close(0)>Study.getValue(0)){
                
    Strategy.doLong("Long",Strategy.CLOSE,Strategy.THISBARmyLotSize);
                
    drawText("Long",BelowBar1,Color.blue,"long"+getCurrentBarCount());
            }
        }
        if(
    Strategy.isLong()){
            if(
    close(0)<Study.getValue(0)){
                
    Strategy.doSell("Close Long",Strategy.CLOSE,Strategy.THISBARmyLotSize);
                
    drawText("XLong",AboveBar1,Color.red,"xlong"+getCurrentBarCount());
            }
        }
        
        return 
    Study.getValue(0);

    Comment


    • #3
      Friday trading

      Thanks!! Got that working. I had to move the statement to main from premain.
      Last edited by glay; 09-01-2006, 08:59 PM.

      Comment

      Working...
      X