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 Balage0922, Today, 07:38 AM
    0 responses
    5 views
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    19 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    6 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Working...
    X