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 kujista, Today, 06:23 AM
    0 responses
    1 view
    0 likes
    Last Post kujista
    by kujista
     
    Started by traderqz, Yesterday, 04:32 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by f.saeidi, Today, 05:56 AM
    1 response
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Jltarrau, Today, 05:57 AM
    0 responses
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Stanfillirenfro, Yesterday, 09:19 AM
    7 responses
    53 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X