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 Brevo, Today, 01:45 AM
    0 responses
    4 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    241 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    6 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X