Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic Stop-losses

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

    Dynamic Stop-losses

    Hi friends,

    I was told to post here instead of Strategy Development. Okay, so I been stuck on creating dynamic stop-losses. I looked at ATM in NInjascript, but I can't use those with historical data, so that was out the window. I then looked at using stop-losses and trail-stops at the same time, but that wasn't possible. So then I decided to look at implementing things with just SetStopLoss method only and then lastly, I tried using the ChangeOrder too.

    So here is my code:



    If anybody can provide me with some useful tips to make dealing with SetStopLoss alot easier, please, please tell me. Unfortunately, I can't cancel previous stop-losses, which might make it easier for me to code. Also, can someone tell me the Pips variable. Like NJ7, we used something like 15 * TickSize for 15 pips. Here, that wasn't compatible, so I was using 0.0015. The problem with that is when I used this on a JPY pair, I will run into problems.

    UPDATE It appears that I didn't change the last part, the short position order management, and it appears that I'm making progress. I'm checking out everything right now to see if my stop-losses are acting the exact way as I have planned. Thanks.
    Last edited by BernWillChris; 08-05-2015, 09:32 AM.

    #2
    Hello,

    After testing a bit on my side, it looks like TickSize functions properly for Forex instruments. Note that it will not necessarily be the pip size from an objective perspective -- rather, it will be the pip size configured on your chart (for that instrument). So for example, looking at half-pip quotes on EURUSD, I'm getting a TickSize value of .00001. This makes sense because of the half-pip quotes. If I were looking at full-pip quotes, it would return .0001. It prints out as "1E-05" in scientific notation, which may be what was throwing you off.

    I can offer a piece of advice for your other issue, as well. If it were me, I would look into using the Unmanaged approach rather than the Managed approach. With the Unmanaged approach, you don't have SetStopLoss(), but you can exercise much tighter control over your own Limit and Stop orders to be used as your stop loss and profit target. You will have much more control over trailing, halting the trail, and any moves you can think of.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Thanks Dave,

      You're going to laugh at me when I tell you this. I thought TickSize had a value that changes for different types of instruments. For instance, the TickSize would be different from EUR/USD (0.0001) vs. USD/JPY (0.01). I thought that was taking care of in the background that is hidden from the programmer so that the programmer can focus on other things.

      As far as Unmanaged approach goes, I tried using it and at the same time,couldn't find content on this forums and sample code that I can look at to see what programmers are ensuring when they use those functions. Because of that, I think it would be less of a headache to try to deal with the Managed approach.

      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, 04-16-2024, 06:09 PM
      4 responses
      12 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      11 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      7 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X