Small code for Money Management. Trade based on money, not lots

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #117149 quote
    Edurecio
    Participant
    Average

    Good morning, I would like to present the small code that I use to compare the performance of a system on different instruments.

    It is based on the fact that normally when we operate in a system we do it based on the money available to do so, but each index has its own value, so at best, a NASDAQ system can apparently generate less performance than a DJI system. But the investment for each lot in NASDAQ is € 425 / lot and in DJI it is € 1400 / lot.

    With this small code I seek to “normalize” the return on investment based on money invested and not in batches.
    What we do is allocate the amount of money we want in the system and the price that each contract has. This function is responsible for assigning the quantity of lots to approximate that quantity (with a decimal)

    At first look we can buy returns and DD for every € 1000 of investment, for example.

    To the administrators: in the forum I did notfind a code of this type, if there is one, you can delete this entry without problem. I do not intend to duplicate content.

    Greetings.

     

    ONCE LotsType             = 1                                //1=by money   0 = lots fixed quantity
    ONCE FixedLots            = 1
    ONCE LotPrice             = 428                              //One Lot NAS Price IG: 428€
    ONCE MoneyToInvest        = 1000
    
    // Lots Management
    if LotsType = 0 Then
    nLots = FixedLots
    elsif LotsType = 1 Then
    nLots = (Round((MoneyToInvest/LotPrice)*10))/10           // (Round(x*10))/10 --> one decimal function
    endif

     

     

    robertogozzi thanked this post
    #117167 quote
    robertogozzi
    Moderator
    Master

    There are some money management snippets, but this seems a bit different.

    I hope many users will find it beneficial. Any suggestion and/or improvement is highly welcome, as always on our forums.

    Thank you for sharing your idea! 🙂

    #117173 quote
    Vonasi
    Moderator
    Master

    Couldn’t LOTPRICE just be CLOSE?

    The downside to this sort of lot size calculation is that inflation is not considered. $1000 back in the 1970’s was worth far more than it is today and stock prices were far lower. So to buy $5000 worth of the Dow Jones back in the 1979’s you would need to have a lot size of somewhere around $9 whereas to buy the same amount today it would be just 20 cents. To keep a constant we would need to add some sort of inflation into our calculation which is not possible.

    In reality just buying a lot size based on a % of an index price will work better over time.

    The attached image is created using this indicator of your code:

    ONCE LotsType = 1 //1=by money 0 = lots fixed quantity
    ONCE FixedLots = 1
    LotPrice = close //One Lot NAS Price IG: 428€
    ONCE MoneyToInvest = 5000
    
    // Lots Management
    if LotsType = 0 Then
    nLots = FixedLots
    elsif LotsType = 1 Then
    nLots = (Round((MoneyToInvest/LotPrice)*10))/10 // (Round(x*10))/10 --> one decimal function
    endif
    
    return nlots
    Screenshot_2-2.png Screenshot_2-2.png
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Small code for Money Management. Trade based on money, not lots


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Edurecio @edurecio Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Vonasi
6 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/18/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...