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 esmall, Today, 07:14 PM
            0 responses
            1 view
            0 likes
            Last Post esmall
            by esmall
             
            Started by Option Whisperer, 05-09-2024, 07:58 PM
            6 responses
            25 views
            0 likes
            Last Post Option Whisperer  
            Started by rayyyu12, Today, 05:38 PM
            0 responses
            12 views
            0 likes
            Last Post rayyyu12  
            Started by xepher101, Yesterday, 12:19 PM
            2 responses
            30 views
            0 likes
            Last Post xepher101  
            Started by thumper57, Today, 04:30 PM
            0 responses
            8 views
            0 likes
            Last Post thumper57  
            Working...
            X