Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnOrderUpdate() or OnExecution???

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

    OnOrderUpdate() or OnExecution???

    code do not what i want ... in simultation. dont fill orders correctly.
    backtesting work fine.

    must i use OnOrderUpdate() or OnExecution???

    ... because the code do not open position or cancel position after realized (P/L). Position is open in the position tab. Not in the Strategy tab.

    protected override void OnBarUpdate()
    {


    //Entry Condition
    if ( (Position.MarketPosition == MarketPosition.Flat) &&
    // (High[2] < High[1]) &&
    (High[1] < High[0]) &&
    (CCI(20)[0] > 0) &&
    (ParabolicSAR(0.09, 0.2, 0.02)[0] < Close[0]) &&
    (DM(10).DiPlus[0] > DM(10).DiMinus[0]))
    {
    EnterLong();
    }

    if ( (Position.MarketPosition == MarketPosition.Flat) &&
    // (Low[1] < Low[2]) &&
    (Low[0] < Low[1]) &&
    (CCI(20)[0] < 0) &&
    (ParabolicSAR(0.09, 0.2, 0.02)[0] > Close[0]) &&
    (DM(10).DiPlus[0] < DM(10).DiMinus[0]))

    {
    EnterShort();

    }

    //Exit Condition

    if ( (Position.MarketPosition == MarketPosition.Long) &&
    (Low[0] < Low[1]))
    {
    ExitLong();
    }

    if ( (Position.MarketPosition == MarketPosition.Short) &&
    (High[1] < High[0]))
    {
    ExitShort();
    }

    }

    best regards

    #2
    excuse me for false posting in false thread.
    can not delete post.

    best regards

    Comment


      #3
      so it works ...

      protected override void OnBarUpdate()
      {


      //Entry Condition
      if ( // (Position.MarketPosition == MarketPosition.Flat) &&
      // (High[2] < High[1]) &&
      (High[1] < High[0]) &&
      (CCI(20)[0] > 0) &&
      (ParabolicSAR(0.09, 0.2, 0.02)[0] < Close[0]) &&
      (DM(10).DiPlus[0] > DM(10).DiMinus[0]))
      {
      EnterLong();
      }

      if ( //(Position.MarketPosition == MarketPosition.Flat) &&
      // (Low[1] < Low[2]) &&
      (Low[0] < Low[1]) &&
      (CCI(20)[0] < 0) &&
      (ParabolicSAR(0.09, 0.2, 0.02)[0] > Close[0]) &&
      (DM(10).DiPlus[0] < DM(10).DiMinus[0]))

      {
      EnterShort();

      }
      /**
      //Exit Condition

      if ( (Position.MarketPosition == MarketPosition.Long) &&
      (Low[0] < Low[1]))
      {
      ExitLong();
      }

      if ( (Position.MarketPosition == MarketPosition.Short) &&
      (High[1] < High[0]))
      {
      ExitShort();
      }
      **/
      }

      Comment


        #4
        Hi whself beginner, I'm not sure I follow your posts - what issue are you experiencing? Could you please clarify? Thanks!
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I would close my position when
          if ((Position.MarketPosition == MarketPosition.Long) & &
          (Low [0] <Low [1]))
          (
          ExitLong ();
          )
          this does not work.

          the positions are not closed or opened by strategy.

          Comment


            #6
            when i insert the strategy in the chart.
            the orders are filled, but then no happens or only sometimes
            orders are correctly filled.

            Comment


              #7
              here some screenshoots,

              i dont know, there are to big differnce between the strategies tab and the position tab.


              but i think it works. the simulation must run on this week and i will show.

              thanx
              Attached Files
              Last edited by whself beginner; 03-25-2009, 06:36 AM.

              Comment


                #8
                It seems you are running into synching issues with your Sim101 account positions and the strategy positions - http://www.ninjatrader-support.com/H...tPosition.html

                What can help is, if you go to Tools > Options > Strategies > NinjaScript and set the 'On starting a real time strategy' to 'Wait until flat before executing live'.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  thanx for your fast answer.

                  Comment

                  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
                  603 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
                  21 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