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

Less complicated implementation of stoploss moving

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

    Less complicated implementation of stoploss moving

    Hello,

    when I am implementing the stoploss-moving in my strategies, I am doing it like this:

    Code:
    if (BarsInProgress==1) {  // 1-TICK TIMEFRAME
    
        if (Position.MarektPosition==MarketPosition.Long) {
            if (Close[0]>=myDoubleValueWhenIWantToMoveMyStopLossUP && dontMoveAnymore==false) {  // moving of stopLoss
                myStopLossLine = myStopLossLine + anyCustomValueForHowMuchIWantToMoveTheStopLoss;
                dontMoveAnymore==true;
            }
    
            if (Close[0]<=myStopLossLine) { // exiting the position when price cross the moving stoploss
                ExitLong();
            }
        }
    
    }

    Is there any way (any function, any method, any class) how to implement this easier?
    Because you can imagine how the source code looks like when I have more layers for the move of the stoploss.
    For example:
    1, On 1005 points move the SL for 5points more
    2, On 1007 points move the SL for 6points more
    1, On 1012 points move the SL for 10points more
    ... etc

    Is there any less complicated way how to do the stoploss move on any specific price, or any specific unrealizedPnL, or move to BE and so on..?
    Is there something for this moving of SL?

    Thank you very much

    #2
    Hello Zooinek,

    We have a reference sample on modifying stop losses and profit targets.

    We also have a way of connecting a NinjaScript automated strategy to an ATM strategy for the management of exits. You can see the help guide article on this as well as the built in SampleAtmStrategy.

    One additional method you have is SetTrailStop() You also have full C# capability at your disposal. You can reference current profit and loss using GetProfitLoss()
    Last edited by NinjaTrader_RyanM1; 04-15-2010, 10:12 AM.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CortexZenUSA, Today, 12:53 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,265 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X