Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Based Stop Reversal on ATR based stop, but only once

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

    Strategy Based Stop Reversal on ATR based stop, but only once

    I have looked everywhere for what I need but can't find it. I need my strategy to perform the following:
    • reverse when the ATR based stop is hit.
    • reversal also has a stop based on the ATR.
    • reverse only the one time until the initial entry criteria is met again.
    • need this reversal order to exit when a certain criteria is hit, say MACD fast length crest/trough breakover.


    Code:
    #region Stoploss reset, ATR Stop set, & Breakeven (BE)
    			// Resets the stop loss to the original value when all positions are closed
    			if (Position.MarketPosition == MarketPosition.Flat)
    			{
    				SetStopLoss(CalculationMode.Ticks, StopLoss);
    				//Set ATR Stop in ticks
    			 	StopLoss = Convert.ToInt32(Math.Round( ATR(ATRStopPeriod)[0] * ATRStopMulti / TickSize));
    			}
    					
    			// If a long position is open, allow for stop loss modification to breakeven
    			else if (Position.MarketPosition == MarketPosition.Long)
    			{
    				// Once the price is greater than entry price +BETrigger ticks, set stop loss to breakeven + 1
    				if (Close[0] > Position.AvgPrice + BETrigger * TickSize)
    					{
    					SetStopLoss(CalculationMode.Price, Position.AvgPrice + 1 * TickSize);
    					}
    			}
    				
    			// If a short position is open, allow for stop loss modification to breakeven
    			else if (Position.MarketPosition == MarketPosition.Short)
    			{
    				// Once the price is greater than entry price +BETrigger ticks, set stop loss to breakeven + 1
    				if (Close[0] < Position.AvgPrice - BETrigger * TickSize)
    					{
    					SetStopLoss(CalculationMode.Price, Position.AvgPrice - 1 * TickSize);
    					}
    			}
    			#endregion
    Thanks!

    #2
    Hello,

    Thank you for the post.

    I am unsure based on what is posted what is not happening correctly, are you saying in addition to what is posted you would like what you listed added? If so I would not be able to assist directly with that but could help with any questions you have related to the syntax used. If you do need it modified for you I can have our business development department provide information on developers.

    If instead you have a specific portion of the syntax that is not working as expected, please share which part of the posted syntax is not working and what tests you have completed, I could provide any incite knowing what the specific problem is.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rocketman7, Today, 02:12 AM
    7 responses
    31 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by guillembm, Yesterday, 11:25 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by junkone, 04-21-2024, 07:17 AM
    10 responses
    149 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by tsantospinto, 04-12-2024, 07:04 PM
    6 responses
    101 views
    0 likes
    Last Post tsantospinto  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    7 responses
    28 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X