Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Breakeven and Get Profit

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

    Breakeven and Get Profit

    Hello,

    I have this logic to get breakeven after some ticks and move stop after reached more ticks. but the second part of the logic (move stop to a certain point), never works. Could you please tell me what's wrong with my logic?

    if (Position.MarketPosition == MarketPosition.Flat
    && Close[1] > SMA(SMALengh)[1]
    && Close[0] < SMA(SMALengh)[0]))

    {
    EnterLong(DefaultQuantity, "");
    SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
    SetStopLoss("", CalculationMode.Ticks, 20, false);
    MovBE = true;
    MovProfit = true;
    }

    if (Position.MarketPosition == MarketPosition.Long && MovBE
    && Close[0] > Position.AvgPrice + MovPrecioBE * TickSize)

    {
    SetStopLoss("", CalculationMode.Price, Position.AvgPrice + 1 * TickSize, false);
    MovBE = false;
    }

    if (Position.MarketPosition == MarketPosition.Long && MovProfit
    && Close[0] > Position.AvgPrice + MovPrecioPP * TickSize)
    {
    SetStopLoss("", CalculationMode.Price, Position.AvgPrice + PP * TickSize, false);
    MovProfit = false;
    }

    #2
    Hello josefo,

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

    I would suggest debugging your code to see if your conditional statements are true.

    Please take a look at this link for some helpful hints on how to debug your code: http://ninjatrader.com/support/forum...58&postcount=1

    I'd strongly recommend using Print statements to check the values of the items being used in your if statements so you can see if your statements are true or not.

    Please, let us know if we 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
    65 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    41 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    23 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    26 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    52 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X