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 rocketman7, Today, 02:12 AM
    5 responses
    21 views
    0 likes
    Last Post rocketman7  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    7 responses
    27 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by samish18, 04-17-2024, 08:57 AM
    17 responses
    65 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by briansaul, Today, 05:31 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by PaulMohn, Today, 03:49 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X