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

  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • matrix74
    started a topic Second Breakeven

    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);
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by Mestor, 03-10-2023, 01:50 AM
16 responses
388 views
0 likes
Last Post z.franck  
Started by rtwave, 04-12-2024, 09:30 AM
4 responses
31 views
0 likes
Last Post rtwave
by rtwave
 
Started by yertle, Yesterday, 08:38 AM
7 responses
29 views
0 likes
Last Post yertle
by yertle
 
Started by bmartz, 03-12-2024, 06:12 AM
2 responses
22 views
0 likes
Last Post bmartz
by bmartz
 
Started by funk10101, Today, 12:02 AM
0 responses
7 views
0 likes
Last Post funk10101  
Working...
X