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

SetStopLoss Question

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

    SetStopLoss Question

    Chris, if I am following you correctly as per your reply here, "Hello RonnieB, thanks for your post.

    You can call SetStopLoss within OnBarUpdate to dynamically change your stop. Set Calculation mode to CalculationMode.Price and then pass in the EMA value for the current bar, so that would be something like:

    SetStopLoss(CalculationMode.Price, EMA3[0]);

    One thing to note will be if you are long or short. If you are long you would want to make sure you are placing the sell stop below the market price and opposite that for short positions.

    Please let me know if I can assist any further with this.". Now if I am following correctly, the setting could be anywhere in OnBarUpdate, and even have two one in the execution block of code for long entry, and also short entry. It would have to first line in the execution code. Thanks in advance for your reply.

    Thanks John

    #2
    Hi John, thanks for posting.

    This question is in reference to this post:
    I'd like my strategy to have a trailing stop based on a user defined amount from a particular EMA indicator line. I've got 3 indicator lines in the strategy defined


    You can call SetStopLoss anywhere. You can target specific entries by using the "FromEntrySignal" parameter e.g.

    //SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop)

    Long Entry Condition:
    SetStopLoss("Long1", ...) //rest of the parameters.
    EnterLong("Long1");
    Short Entry Condition:
    SetStopLoss("Short1", ...); //rest of the parameters
    EnterShort("Short1");

    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by geddyisodin, Yesterday, 05:20 AM
    7 responses
    45 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by gbourque, Today, 06:39 AM
    2 responses
    5 views
    0 likes
    Last Post gbourque  
    Started by cre8able, Yesterday, 07:24 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by cocoescala, 10-12-2018, 11:02 PM
    6 responses
    939 views
    0 likes
    Last Post Jquiroz1975  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X