Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting size of Tick in code (for FX)

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

    Setting size of Tick in code (for FX)

    Hi guys. There are a few questions here, all related. I know you can set the size of a tick in the options menu for FX (pip, half pip, tenth pip).

    1. How would you do this in code? Is it something like TickSize = ?; Maybe TickSize = 0.00005 (for half a pip)? Would this go under Initialize() or OnStartUp()?

    2. Also, would it be possible to check the instrument being run against (so if it's USDJPY it would only be 0.005)? I'm not sure how you'd check the instrument.

    This is so I can set stop loss and take profit levels based off of ticks and have it not be dependent on what the user has set as an option in their own instance (would of course give very different results!).

    3. Would this override carry over into backtesting, regardless of what the user has selected in the GUI? (especially for use in Slippage field which takes a tick value)

    4. Not related to TickSize, but for SetStopLoss and SetProfitTarget - if you put them under OnBarUpdate(), can you check if position is long or short and assign different parameters to them? That is, can you do something like the following:

    if (Position.MarketPosition == MarketPosition.Short)
    {
    SetStopLoss( .... );
    SetProfitTarget(...);
    }
    if(Position.MarketPosition == MarketPosition.Long)
    {
    SetStopLoss(....);
    SetProfitTarget(....);
    }

    Or does it make more sense to do something like
    SetStopLoss("Long1", ...);
    SetStopLoss("Short1", ...);
    Just thought of this one... would these 2 kind of be equivalent (assuming only one trade active) ?

    Thanks again guys.
    Last edited by Locke; 01-14-2015, 09:41 AM.

    #2
    Hello Locke,

    Thank you for your post.

    1. Unfortunately, there is no option to set the 'Quote currencies in' option in the code. This can only be set under Tools > Options > Data.

    2. It is possible to check the instrument using Instrument.MasterInstrument.Name: http://www.ninjatrader.com/support/h...trument_na.htm

    3. There would not be an override that could be set in the code.

    4. You could have different values for the Stop Loss and Profit Target as you listed when Long or Short. you would also want to reset the values when flat so the previous values are not used. You can find an example of this at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3222

    Comment


      #3
      Thanks Patrick. I guess there are only 3 values TickSize can take, so I can probably do a check for all 3 and modify my variables in the code accordingly.

      Very helpful!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      672 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X