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 StockTrader88, 03-06-2021, 08:58 AM
    45 responses
    3,991 views
    3 likes
    Last Post johntraderuser2  
    Started by TAJTrades, Today, 09:46 AM
    0 responses
    7 views
    0 likes
    Last Post TAJTrades  
    Started by rhyminkevin, Yesterday, 04:58 PM
    5 responses
    62 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Started by realblubb, Today, 09:28 AM
    0 responses
    8 views
    0 likes
    Last Post realblubb  
    Started by AaronKoRn, Yesterday, 09:49 PM
    1 response
    19 views
    0 likes
    Last Post Rikazkhan007  
    Working...
    X