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

SetAutoTrail()

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

    SetAutoTrail()

    How about support for the AutoTrail ATM function inside a strategy?

    SetAutoTrail(CalculationMode.Ticks, 12,6,6);

    The above would be a great addition to the Strategy development commands.

    Currently I'm writing a few lines of code to support :

    1. Waiting for 6 ticks in profit
    2. Setting StopLoss back 12 ticks
    3. Adjusting every 6 ticks in profit.

    It would be nice to replace that code with the above command.

    Any chance of adding this suggestion to the development work schedule?

    #2
    Hello rcsingleton,
    Thanks for your note.

    You can do it by simply reassigning the SetStopLoss method again and further custom code your strategy. A sample code will be like:

    Code:
    //in variable
    int profitTicks = 6;
    
    //in OnBarUpdate
    if (Position.MarketPosition == MarketPosition.Long && Close[0] >  Position.AvgPrice + profitTicks * TickSize)
    {
    	profitTicks += 6;
    	SetStopLoss(CalculationMode.Price , Close[0] - 12 * TickSize); 
    }
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Uregon, Today, 03:44 AM
    0 responses
    0 views
    0 likes
    Last Post Uregon
    by Uregon
     
    Started by CyberNate, 11-17-2020, 08:15 PM
    2 responses
    424 views
    0 likes
    Last Post nurpalgo  
    Started by sdauteuil, 09-23-2021, 10:16 AM
    7 responses
    1,247 views
    0 likes
    Last Post marcus2300  
    Started by sofortune, 05-18-2024, 11:48 AM
    2 responses
    34 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by Zach55, 02-19-2024, 07:22 PM
    2 responses
    67 views
    0 likes
    Last Post lbadisa1  
    Working...
    X