Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Double into int

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

    Double into int

    My objective is to define the current number of traded contracts as a % of actual capital.
    So after having defined
    capital=start+Performance.RealtimeTrades.TradesPerformance .Currency.CumProfit;
    I wish to define the number of traded contracts as eg
    nbcontracts=Math.Floor(capital/10000)
    The problem is that the nbcontracts is now a double that I wish to transform into a int to be able to use instructions like enterlong.
    So the question is: how to transform a double (which is in fact by construction an integer) to the int class.
    NB: Math.Floor exits a double as result...

    #2
    nbcontracts=(int)(capital/10000 - 0.5)

    Comment


      #3
      Thanks a lot

      Why -0.5?
      (Int) rounds to the nearest integer?

      Comment


        #4
        I believe Baruch meant to emulate the 'floor' part....

        Comment


          #5
          OK

          it seems to partially work: no compiling error any more but...
          Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit
          doesn't seem to work (as its name seems to say) for backtesting strategies on past data. Is there an equivalent variable for obtaining quickly the "current" P&L generated on a backtest at a given time? I would just like to allocate a given percentage of my capital at any time.

          Comment


            #6
            Please try Performance.AllTrades ... for backtesting purposes.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            44 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X