Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

setstoploss setprofitTarget

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

    setstoploss setprofitTarget

    Hi,

    I created a strategy using in OnBarUpdate the following two:
    -------------------------------------------------------------
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    }
    --------------------------------------------------------------
    if (Position.MarketPosition == MarketPosition.Flat){
    SetStopLoss(CalculationMode.Ticks, 3);
    SetProfitTarget(CalculationMode.Ticks, 4); }

    --------------------------------------------------------------
    1#When the strategy enters Long/Short (in replay), I would like to manually change stoploss/target in the Dome. This works as long as price is moving within the same bar. As soon as a new bar formes, it resets itself to the above settings even when I'm in a position?!

    How come? Any suggestions how to solve this ?

    ps 2# If using SetStopLoss & SetProfitTarget, is that created as bracket or oco or ... ?
    3# I also noticed that Position.MarketPosition == MarketPosition.Long or short is seen as Flat until the next bar creation begins ? How come?

    Hope you can help me out here,

    Thanks in advance,

    Greetings from the netherlands,
    Last edited by Creamers; 07-20-2008, 08:44 AM.

    #2
    >> I would like to manually change stoploss/target in the Dome.
    Unfortunately this is not supported. You can't manually change the prices of order placed by NinjaScript strategies

    >> If using SetStopLoss & SetProfitTarget, is that created as bracket or oco
    yes

    >> I also noticed that Position.MarketPosition == MarketPosition.Long or short is seen as Flat until the next bar creation begins
    Not sure I follow. Position will be reported as Long/Short as long as there is a position.

    Comment


      #3
      manually

      >> I would like to manually change stoploss/target in the Dome.
      >>>Unfortunately this is not supported. You can't manually change the prices of order placed by NinjaScript strategies

      I created a stategy to enter the market automatically because it goes lighting fast. What alternative could there be made so I ONLY enter the market automatically with a strategy but manage my position manually ?

      >> I also noticed that Position.MarketPosition == MarketPosition.Long or short is seen as Flat until the next bar creation begins
      >>>Not sure I follow. Position will be reported as Long/Short as long as there is a position.

      If I'm long or short within the candle it triggered, MarketPosition.Long is not true untill the next rangebar ! (replay mode)
      Is there an alternative to see if I'm long or short ?

      Comment


        #4
        You could try an ATM strategy (e.g. on the SuperDOM). However, it's not as flexible as a NinjaScript strategy.

        Position.MarketPosition= Long/Short will be reported as a position has been entered, meaning an order was placed and filled and (!) OnBarUpdate is triggered again (which is on the next bar). To trigger OnBarUpdate on every tick see CalculateOnBarClose=false: http://www.ninjatrader-support.com/H...BarClose1.html

        Comment


          #5
          manually

          Thanks for explaining, makes totally sense now !!

          But I have still one question left, it's about manually editing a strategy target/stoploss.
          I know you try to answer in concept of you support and don't go into technical details, but if you could just give me a hint ...That way I can go and investigate it on my own.

          (With ATM you mean sending AtmStrategyCreate() from within a strategy condition etc , right?)

          But I assume Ninjatrader has also other posiblilities to interact with a strategy?

          I hope you can give me a hint,

          Anyway, thanks for answering the previous questions ! Have a nice sunday!

          greetings,
          Last edited by Creamers; 07-20-2008, 12:42 PM.

          Comment


            #6
            The idea of linking an ATM strategy inside a NinjaScript Strategy is that the NS strategy will fire off the entry order and then the ATM strategy will handle the protective exit orders.

            You can interact with NinjaScript Strategies via read/write to text files if you would like. There is a reference sample you can check out in the Reference Sample section just about this. It is titled something along the lines of Reading from a text file.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X