Announcement

Collapse
No announcement yet.

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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X