Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use CalculationMode.Currency under OnBarUpdate

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

    How to use CalculationMode.Currency under OnBarUpdate

    The screenshot probably explains what I am trying to accomplish. I have successfully coded a system where it will enter an initial stop when a position is opened but if I manually move the stop using Chart Trader it will stay where I put it (as opposed to using SetStoploss which resets to default on every bar). But I need to define where the initial stop needs to be. This is no problem if I design the strategy to a specific instrument: I just do the math of how many points/ticks away from current price would equal the dollar amount I want. But this latest strategy I am developing to work across a basket of instruments, so that would be different on each.
    So thus the dilemma, how can I get the strategy to make that calculation?Click image for larger version

Name:	Screenshot_1.jpg
Views:	268
Size:	38.5 KB
ID:	1257235

    #2
    Hello RaygunWizzle,

    The close price is already a price so if you wanted to subtract an amount of price from that you would just subtract that number directly. If you wanted to convert the price to an amount of dollars you would have to know the instruments point size and tick size and then use math to calculate the amount of currency from that. For example the ES point size is 50 and its tick size is 0.25, so:

    0.25*50=12.5$ per tick.

    You could reverse that as well:

    12.5$ / 50 = 0.25
    0.25 / TickSize = 1 tick.

    In that type of math you would take your dollar amount and convert it to an amount of ticks and then subtract the ticks from the price

    Close[0] - (numberOfTicks * TickSize)

    Comment


      #3
      Yes like I said that is how I am currently doing it but I have to code it specific to each instrument and with this new strategy I want to run it across a basket of instruments. So my question was is there a way to code in for it to automatically do that math just like it does for SetStopLoss.

      Comment


        #4
        Maybe if I show you the B part of this coding you will see the operation I am trying to accomplish. This coding works perfectly how I want it to... if I define each strategy to a specific instrument.Click image for larger version

Name:	Screenshot_1.jpg
Views:	231
Size:	92.0 KB
ID:	1257343

        Comment


          #5
          Hello RaygunWizzle,

          If you want to support a variety of instruments you would need to still use math to calculate that value. You can use the properties TickSize to know the instruments tick size or the PointValue from the master instrument:


          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          50 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 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