Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongStop()

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

    EnterLongStop()

    Hey @ll,

    i am working on my first real strategy and iÄve got some struggle with the order management. Like you can see in the picture, i want to put a enterlongstop at the top of the candle when the EMA is crossed

    crossedbelow & above wasn't working (maybe cause of calculateOnBarClose = false?). Somewhere i have a mistake and i am sorry for steal your time, but i really can't find it.


    if ( Opens[0][1] > EMA(Opens[0],20)[1]
    && Lows[0][1] < EMA(Opens[0],20)[1]
    && entryOrder == null
    )
    {
    longbool = true;
    SLLong = (Lows[0][LowestBar(Lows[0],1)]);
    entryOrder = EnterLongStop(1,Highs[0][1],"BUY"+(BarsPeriods[BarsInProgress].Value));
    LongtradeStop = Lows[0][1];
    ELS = Highs[0][1]; //EnterLongStop
    }


    if ( Opens[0][1] < EMA(Opens[0],20)[1]
    && Highs[0][1] > EMA(Opens[0],20)[1]
    && entryOrder == null
    )
    {
    shortbool = true;
    SLShort = (Highs[0][HighestBar(Highs[0],1)]);
    entryOrder = EnterShortStop(1,Lows[0][1],"SELL"+(BarsPeriods[BarsInProgress].Value));
    ShorttradeStop = Highs[0][1];
    ESS = Lows[0][1];



    }


    #endregion
    #endregion

    #region Keep Order Alive
    if ( longbool == true )
    {
    entryOrder = EnterLongStop(1,ELS,"BUY"+(BarsPeriods[BarsInProgress].Value));
    }

    if ( shortbool == true)
    {
    entryOrder = EnterShortStop(1,ESS,"SELL"+(BarsPeriods[BarsInProgress].Value));
    }


    // Abbruchbedingung für Limit
    if((longbool == true && Lows[0][0] < LongtradeStop)
    || (shortbool == true && Highs[0][0] > ShorttradeStop)
    )
    {
    longbool = false;
    shortbool = false;
    CancelOrder(entryOrder);
    entryOrder = null;
    }





    Home you get what i am working on :-)
    Attached Files
    Last edited by eNhale; 12-05-2014, 02:41 PM.

    #2
    eNhale,

    Is this the exact code you are using?

    I wouldn't expect this work as you have && starting your IF statements which will cause compile errors.

    Additionally, if you are checking the cross you need to compare to the previous values as well. This is how the CrossAbove and Below work as well.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hey Cal,

      no i made it easy to read for you so you don't have to deal with my var-names. i don't have compile errors but sometimes the crossbow wasn't working like i wanted it ( CalculateOnBarClose = false).

      Now i try to make it work with CalculateOnBarClose=true because i don't want to buy when the CrossBelow is happening.

      is the part of keeping the order alive even necessary? With COBC=false it was, because every Order was alive for 1 bar update..... my system is working when i have a v-reversal and the next bar is higher then the crossing one

      Comment


        #4
        Hello eNhale,

        It may not be necessary but on the next bar update it will cancel if the order is not resubmitted.

        Is it the checks are just not working? or are you getting them at incorrect places?
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 04-23-2024, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        193 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,235 views
        0 likes
        Last Post xiinteractive  
        Working...
        X