Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Confused By stops

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

    Confused By stops

    Hey guys,

    First time poster here.
    Basically I've spent the last two days trying to figure out how to back test a simple strategy (I thought?). For some reason with all the ways I've tried I can't seem to get the Exits to fire correctly. If anyone wants to take a gander and give me some tips would be much appreciated.

    The idea was to write some code to enter short when RSI falls under 70 and you then get a cross of the MACD in the same direction within 5 bars (Bar must close, order is placed on next bar on a 233 tick chart). A stop would be placed at the High of the previous bar and a trailing stop would start when the price falls below the entry by 5 ticks.

    Again, any tips would be helpful, right now it seems I'm getting pretty close, but I have some odd exits firing, or not firing at all.
    Attached Files

    #2
    Hello Ashai,

    Thank you for your inquiry and welcome to the NinjaTrader Support Forum!

    Looking through your code, it looks like you are incorrectly checking to see if the noTrail boolean is true for your conditions.

    In order to check for equality in conditional statements, you would use two equal (==) signs.

    Example:
    Code:
    //If price drops below last bars low and we have no trailing stop exit
    if(Position.MarketPosition == MarketPosition.Long && noTrail == true && Low[0] < (Position.AvgPrice - (13 * TickSize)))
    {
         // logic
    }
    Please, let me know if I may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    111 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    59 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    38 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    42 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    78 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X