Announcement

Collapse
No announcement yet.

Lot size

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

  • Lot size

    Hi, when backtesting a strategy with EFS, the lt size is allowed. Is any ther way to make the lot size a variable of a certain $quantity that you have available. That is insteas of trading 10 lots, you want to buy 1000 USD/the close of the share you are interested in.
    Thank you
    Alex

  • #2
    Alex
    Yes it is possible. You would create a variable for the dollar amount then divide that by the Close and round the result (see enclosed example). At that point you would use the result as the lot size parameter in the doLong() or doShort() functions.
    Alex

    PHP Code:
    function main(){
     
        var 
    myDollarAmount 1000;
        var 
    myLotSize Math.floor(myDollarAmount/close(0));
     
        if(
    myCondition){
            
    Strategy.doLong("Long"Strategy.CLOSEStrategy.THISBARmyLotSize);
        }
        
    //rest of your code 

    Comment

    Working...
    X