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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            118 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            166 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            85 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            130 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            88 views
            0 likes
            Last Post PaulMohn  
            Working...
            X