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....
        BertrandNinjaTrader Customer Service

        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.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ageeholdings, Today, 07:43 AM
            0 responses
            5 views
            0 likes
            Last Post ageeholdings  
            Started by pibrew, Today, 06:37 AM
            0 responses
            4 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            12 views
            0 likes
            Last Post burtoninlondon  
            Working...
            X