Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy entering long and short at the same time.................HELP

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

    Strategy entering long and short at the same time.................HELP

    This:

    if(BarsInProgress == 0)
    {
    EMA MovingAverage = EMA(smaPeriod);
    // EMA MovingAverageShort = EMA(smaPeriodShort);



    if(Position.MarketPosition == MarketPosition.Flat)
    {
    if(MovingAverage[0] > MovingAverage[1]);
    {
    EnterLong(1,1,"Enter Long");
    Print( "MovingAverage 0 " + MovingAverage[0] + " MovingAverage 1 " + MovingAverage[1]);
    }
    if(MovingAverage[0] < MovingAverage[1]);
    {
    EnterShort(1,1,"Enter Short");
    Print( "MovingAverage 0 " + MovingAverage[0] + " MovingAverage 1 " + MovingAverage[1]);
    }
    }


    Is Producing This:
    02/01/2009 7:30:00 AM Entered internal PlaceOrder() method at 02/01/2009 7:30:00 AM: BarsInProgress=1 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Enter Long' FromEntrySignal=''
    MovingAverage 0 887.388030127119 MovingAverage 1 887.384392238949
    02/01/2009 7:30:00 AM Entered internal PlaceOrder() method at 02/01/2009 7:30:00 AM: BarsInProgress=1 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Enter Short' FromEntrySignal=''
    MovingAverage 0 887.388030127119 MovingAverage 1 887.384392238949





    ...................

    WHYYY is it submitting both orders??? I've spent 3 hours changing all kinds of trivial things to try and make it stop.... my optimizer period is set to 45 minutes, and I've added a 1 minute series to submit orders to.

    I spend more time trying to hash out NT script crap then anything else... I hope I'm overlooking something very obviously or I'm starting to lose faith. Is this some kinda decimal rounding thing in the > < calculation? it displays all the decimals in the print statement. How can it be larger and smaller at the same time?!?! Even if it was knocking off decimals, I'm using > not >= .......Help.

    Thanks.

    #2
    Hello waynewright33,

    Corrected response in next post.
    Last edited by NinjaTrader_PatrickH; 07-30-2013, 12:10 PM.

    Comment


      #3
      Hello waynewright33,

      A colleague of mine pointed out an item here I overlooked; the if statements for these conditions have a ';' at the end of them.

      Change your if statements from the following:
      Code:
      if(MovingAverage[0] > MovingAverage[1]);
      if(MovingAverage[0] < MovingAverage[1]);
      To the following:
      Code:
      if(MovingAverage[0] > MovingAverage[1])
      if(MovingAverage[0] < MovingAverage[1])
      Please let me know if I may be of further assistance.

      Comment


        #4
        An item I clearly overlooked as well... I wish I could click the thank you button x100.

        I had hoped it was something simple, thank you very very much, and sorry if I seemed frustrated... I'm sure you guys know the pains of hours of debugging, and it was clearly an oversight on my end.

        Thanks!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X