Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

for example: long, setprofittarget, short

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

    for example: long, setprofittarget, short

    for example: long, setprofittarget, short

    How can I find help in this problem.
    Please have a look at the below mentioned example. I wonder if somebody could help me with this.
    I want after LONG, SETPROFITTARGET that then follows SHORT. Or SHORT, SETPROFITTARGET and then LONG. I do not want after for example LONG, SETPROFITTARGET that it keeps on with LONG, even the signal is still LONG. I would like to buy just once. But I want the next buy after changing from LONG to SHORT.
    Thank you in advance for your help.

    protected
    overridevoid Initialize()
    {
    CalculateOnBarClose = true;
    SetProfitTarget("", CalculationMode.Ticks, 20);
    setStopLoss("", CalculationMode.Ticks, 20, false);
    }

    protectedoverridevoid OnBarUpdate()

    {
    if (CrossAbove(SMA( 10 ), SMA( 30 ), 1))

    EnterLong();

    elseif (CrossBelow(SMA( 5 ), SMA( 20 ), 1))

    EnterShort();
    }




    Last edited by giorgos; 07-17-2011, 03:46 PM.

    #2
    Hello giorgos,

    For this reversal long > short on a limit order you must submit instead an EnterShortLimit(). A simple example of this is:

    if (Position.MarketPosition == MarketPosition.Long)
    EnterShortLimit(Position.AvgPrice + TickSize * 20, "limitReversalEntry");

    A common issue with limit reversals is the potential to run into internal order handling rules with any competing orders, like those placed with Set statements. To check messages related to these rules, set TraceOrders = true; in your strategies Initialize() method and view in Tools > Output window.

    Internal order handling rules are detailed here:


    Handling the cancel logic and timing of all orders can be involved and requires an understanding of advanced order handling concepts.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hello Ryan.
      Thank you very much for your quick answer. I still wonder if you could be so kind to help me by giving your example exactly on my example. What i mean is, you gave me help with an example. Could you write your example exactly on my example (overwrite it on my example). Because i tryed to understand and practice what you wrote but i could not.
      I dont know if you understand what i would like you to do. Just use my example to explain to me your help.
      Thank you very much again.

      Comment


        #4
        Yes, I used the content of your post to produce my example.

        In your example you have a SetProfitTarget() at 20 ticks. In my example, this is a reversal limit order at 20 ticks from the entry price.

        For a more customized and professionally developed solution, consider hiring a NinjaScript consultant.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        14 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        11 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        9 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        4 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        31 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X