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 Fitspressorest, Today, 01:38 PM
        0 responses
        2 views
        0 likes
        Last Post Fitspressorest  
        Started by Jonker, Today, 01:19 PM
        0 responses
        2 views
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by futtrader, Today, 01:16 PM
        0 responses
        6 views
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,791 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        844 views
        0 likes
        Last Post emuns
        by emuns
         
        Working...
        X