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 1001111, Today, 01:35 AM
      0 responses
      5 views
      0 likes
      Last Post 1001111
      by 1001111
       
      Started by ETFVoyageur, Yesterday, 07:05 PM
      1 response
      16 views
      0 likes
      Last Post ETFVoyageur  
      Started by MarianApalaghiei, Today, 12:35 AM
      1 response
      8 views
      0 likes
      Last Post MarianApalaghiei  
      Started by Rogers101, 05-05-2024, 11:30 AM
      17 responses
      57 views
      0 likes
      Last Post Rogers101  
      Started by haas88, 03-21-2024, 02:22 AM
      13 responses
      156 views
      0 likes
      Last Post haas88
      by haas88
       
      Working...
      X