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

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 bortz, 11-06-2023, 08:04 AM
            47 responses
            1,605 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            13 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X