Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Stop Loss fails

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

    Stop Loss fails

    Hello,

    I ask for your help because I do not know what I am doing wrong in this operation.

    If I run the attached code after 04/27/2021 at 21:00:01 (Only the second block of the code is executed)(Note Time Zone), everything is fine.

    But if I run it from before that date (Both code blocks are executed), it fails. It seems as the new StopLoss did not act, since the error tells me that the value of the StopLoss is not valid for the market price, but it indicates the value of the Stop Loss that is set in the first block.

    What I am doing wrong?

    Any help will be greatly appreciated.

    Thanks in advance.

    TEST ENVIRONMENT:

    Account: Simulated account with $ 10,000 of initial balance
    Connection: Playback Connection
    Instrument: M6E 06-21
    Candles width: 60-minutes
    Ninja Version: Ninja Trader 8 version 8.0.24.2 64-bit.
    Time Zone: (UTC+01:00) Bruselas, Copenhague, Madrid, París
    Attached Files

    #2
    Hello JoseFRS,

    Thanks for your post.

    We recommend using bar close time instead of connection time for test examples.

    When setting the new value of the stop-loss, it would be a good practice to first check that the stop-loss is being set to a correct value relative to the current price.

    When using signal names, please use different signal names for your entries, you are using the same signal name for both the long and the short entries.

    In the 2nd block you are using ExitLong() and EnterShort(), keep in mind that this can cause unexpected positions because the Entry methods will automatically close positions in the opposite direction. If you are seeking to reverse the position then you would only need the entry methods (but again with different signal names for the entries and the associated stoploss).
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Thank yoy very much for all again.

      Your advices works fine.

      A greeting.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by mattbsea, Today, 05:44 PM
      0 responses
      4 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,282 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      20 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Working...
      X