Announcement

Collapse
No announcement yet.

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 -

    http://www.ninjatrader-support2.com/...ead.php?t=3627

    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 salination2, Yesterday, 07:21 PM
1 response
6 views
0 likes
Last Post s.kinra
by s.kinra
 
Started by aarons34, Yesterday, 08:11 PM
0 responses
7 views
0 likes
Last Post aarons34  
Started by Shiner452, Yesterday, 06:55 PM
0 responses
3 views
0 likes
Last Post Shiner452  
Started by Aquatrade, Yesterday, 06:22 PM
0 responses
3 views
0 likes
Last Post Aquatrade  
Started by trader3000a, Yesterday, 02:04 PM
2 responses
26 views
0 likes
Last Post trader3000a  
Working...
X