Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Second Breakeven

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

    Second Breakeven

    hello
    I would have added a second breakeven the first 5 + 1 and the second
    7 + 4 only when the market goes over +7 ticks in my favor and then
    goes back to +6, the breakeven "dances" between +1 and + 4 This is the
    code, am I probably missing something?
    thank you very much


    Massimiliano





    protected override void OnBarUpdate()
    {
    if (CurrentBar < BarsRequiredToTrade)
    return;
    // Resets the stop loss to the original value when all positions are closed
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    TriggerState = 0;
    SetStopLoss(CalculationMode.Ticks, StopLossTicks);
    }
    // If a long position is open, allow for stop loss modification to breakeven
    else if (Position.MarketPosition == MarketPosition.Long)
    {
    // Once the price is greater than entry price+3 ticks, set stop loss
    to breakeven
    if (Close[0] > Position.AveragePrice + 3 * TickSize)

    {
    TriggerState=1;
    SetStopLoss(CalculationMode.Price, Position.AveragePrice +1*TickSize);
    }
    //
    // Once the price is greater than entry price+3 ticks, set stop loss
    to breakeven
    if (Close[0] > Position.AveragePrice + 7 * TickSize)
    {
    TriggerState= 2;
    SetStopLoss(CalculationMode.Price, Close[1] +4*TickSize);
    }

    #2
    Hello Massimiliano,

    This appears to be the same text in an email I have received.

    Are you creating multiple inquiries for the same question?

    While we are happy to assist on the forums or with you privately through email with our platformsupport [at] ninjatrader [dot] com address, we respectfully ask that you only create one inquiry. This can be privately in email or can be a public thread on the forum.

    If you would no longer like to communicate through email and you would like to communicate on the forums, please let us know so and we will converse solely through the forums.

    Creating both a forum thread and an email with platformsupport [at] ninjatrader [dot] com will create two separate tickets and may cause multiple technicians to start at the beginning of reviewing your inquiry, tying up resources with our platform support and delaying our ability to respond to all customers in a timely manner.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by junkone, Today, 11:37 AM
    2 responses
    14 views
    0 likes
    Last Post junkone
    by junkone
     
    Started by frankthearm, Yesterday, 09:08 AM
    12 responses
    44 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by quantismo, 04-17-2024, 05:13 PM
    5 responses
    35 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by proptrade13, Today, 11:06 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    35 views
    0 likes
    Last Post love2code2trade  
    Working...
    X