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 funk10101, Today, 12:02 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by GLFX005, Today, 03:23 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by nandhumca, Yesterday, 03:41 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by The_Sec, Yesterday, 03:37 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by vecnopus, Today, 06:15 AM
    0 responses
    1 view
    0 likes
    Last Post vecnopus  
    Working...
    X