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

Stoploss and Profittarget Problem

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

  • kaywai
    replied
    Thanks Bertrand! Got it now!

    Leave a comment:


  • kaywai
    replied
    Sorry Bertrand. is this "#" the rhomb symbol you are talking about? when you say wrap code tags around it, do you mean that I paste the code inbetween "
    Code:
    " and "
    "?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Just wrap code tags around it...the rhomb symbol when you post...

    Looks then like below -

    Code:
     
    MyCodeIsHappyInThisBox

    Leave a comment:


  • kaywai
    replied
    May I ask how you guys post your codes in that blue box?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Please run the strategy with TraceOrders = true in your Initialize(), this will give you insight into it's order behavior -

    Leave a comment:


  • thunderbolt78
    replied
    i have no error,

    if i run the script with setstoploss and setprofittarget only Profittargt will filled. No Stoploss will triggered. I i run

    if (Position.MarketPosition == MarketPosition.Long)
    // SetProfitTarget(CalculationMode.Price, Position.AvgPrice + range);
    SetStopLoss(CalculationMode.Price, Position.AvgPrice - range);

    i have an Entry and after this the position will be stopped out but not with the right range.

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    What error do you get with the targets? You would need to reset those as well when flat...

    Leave a comment:


  • thunderbolt78
    replied
    Thx bertrand

    entry and PT work, SL don´t work

    Here is my Code

    Code:
    protected override void OnBarUpdate()
            {
                // Condition set 1
                
                if (Position.MarketPosition == MarketPosition.Flat)
                    {
                    SetProfitTarget(CalculationMode.Ticks, 20);
                    }
    
                if (entry condition)
                    {
                    range = Math.Abs(High[0] - Low[0]);
                    EnterLong();
                        }
                if (Position.MarketPosition == MarketPosition.Long)
                SetProfitTarget(CalculationMode.Price, Position.AvgPrice + range);
                SetStopLoss(CalculationMode.Price, Position.AvgPrice - range);
            }
    Last edited by thunderbolt78; 03-02-2010, 06:59 AM.

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Sorry, I'm not aware of a direct sample for this, the general idea is like demonstrated in this snippet below -

    Code:
     
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetProfitTarget(CalculationMode.Ticks, 20);
    }
    
    if (CrossAbove(SMA(Fast), SMA(Slow), 1))
    {
    range = Math.Abs(High[1] - Low[1]);
    EnterLong();
    }
    
    if (Position.MarketPosition == MarketPosition.Long)
    SetProfitTarget(CalculationMode.Price, Position.AvgPrice + range);

    Leave a comment:


  • thunderbolt78
    replied
    hi this is what i´m locking for, but i have no idea how i make this ?

    is there a reference oder a code sample ? Sorry ..

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    You would need to custom code to achieve this - record the range of your entry bar at time of entry and then call SetStopLoss / SetProfitTarget to place the exit bracket at your desired values.

    Leave a comment:


  • thunderbolt78
    replied
    hi,

    thanks for your fast reply, but if i use the normal setstoploss ans setprofittarget i can only use normal values.

    i the 30 min bar 40 ticks i need 40 ticks stop and profit from entry if the bar has got 30 ticks i need 30 ticks SL and PT. How i can set the ticksize of PT and SL to the ticksize of my entrybar ?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    You could directly use SetProfitTarget and SetStopLoss set to CalculationMode.Ticks for this, as they would automatically reference your entryPrice directly when issuing the needed bracket orders (those Set Methods would be OCO'ed as well).

    Leave a comment:


  • thunderbolt78
    started a topic Stoploss and Profittarget Problem

    Stoploss and Profittarget Problem

    Hi there, i have read many Hours in this forum, but i don´t find a solution.

    Here is my problem

    i will trade a 30 min bar. the ATR of this bar is 20 ticks for example. If i enter this bar i will make a profit target of this 20 ticks. I will make a stoploss of this 20 ticks. The Position will be stopped out or will go in profit. If the Position is closed, with or without Profit the next bar has a range of 15 ticks for example. So i need a PT of entry + 15 and a Stoploss of Entry -15. How can i make this ?

    please help me

Latest Posts

Collapse

Topics Statistics Last Post
Started by usazencort, Today, 01:16 AM
0 responses
1 view
0 likes
Last Post usazencort  
Started by kaywai, 09-01-2023, 08:44 PM
5 responses
602 views
0 likes
Last Post NinjaTrader_Jason  
Started by xiinteractive, 04-09-2024, 08:08 AM
6 responses
22 views
0 likes
Last Post xiinteractive  
Started by Pattontje, Yesterday, 02:10 PM
2 responses
20 views
0 likes
Last Post Pattontje  
Started by flybuzz, 04-21-2024, 04:07 PM
17 responses
230 views
0 likes
Last Post TradingLoss  
Working...
X