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 AaronKoRn, Today, 09:49 PM
            0 responses
            6 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Today, 08:42 PM
            0 responses
            9 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Today, 07:51 PM
            0 responses
            10 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,976 views
            3 likes
            Last Post jhudas88  
            Started by rbeckmann05, Today, 06:48 PM
            0 responses
            9 views
            0 likes
            Last Post rbeckmann05  
            Working...
            X