Problem with contract size in BUY order when using a variable with round fun.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #64421 quote
    Alberto Lucchese
    Participant
    Average

    Hello,

    I want the quantity of contract to increase/decrease as the strategyprofit increases. So i tried the following code together with the BUY order command:

    ContractSize=round(1+strategyProfit/10000) ///minimun size is 1, increase when profit is more than 10K
    
    // Then use the BUY command
    BUY ContractSize Contract at market // this does not works, BUY is never executed
    

    If I change the ContractSize variable and set any integer number (1, 2, etc), it works. So I’m  not sure if the result of the round function is giving me trouble.

    anyone has had the same problem?

    #64446 quote
    Nicolas
    Keymaster
    Master

    Try with:

    ContractSize=max(1,round(1+strategyProfit/10000))

    If it doesnt work, try to [scode]GRAPH ContractSize[/scode] in your backtest.

    Alberto Lucchese thanked this post
    #64457 quote
    Alberto Lucchese
    Participant
    Average

    Thanks!

    I was looking for a way to check the variables values, I’ll try that and get back to you.

    #64643 quote
    Alberto Lucchese
    Participant
    Average

    The problem was i was using pipvalue to calculate the contract size with the SP500 index. I started using the SP500 Futures instead (ESXXXX) and the formula started working.

     

    thanks a lot!

    #64646 quote
    Leo
    Participant
    Veteran

    Try this:

    n = 1 + (strategyprofit / (134*pipvalue))
    n = round(n * 100)
    n = n / 100
    n = max(1,n)
    Alberto Lucchese thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Problem with contract size in BUY order when using a variable with round fun.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Leo
8 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/05/2018
Status: Active
Attachments: No files
Logo Logo
Loading...