Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry and Exit

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

    Entry and Exit

    Hello,

    I use the following code for entry and exit. However, it takes the long trade only and not the short trade.

    if (Position.MarketPosition==MarketPosition.Flat)
    {
    if (CrossAbove(EMA(Fast), EMA(Slow), 1))
    {
    EnterLong(1);
    SetStopLoss(CalculationMode.Ticks,SL);
    }
    if (CrossBelow(EMA(Fast), EMA(Slow), 1))
    {
    EnterShort(1);
    SetStopLoss(CalculationMode.Ticks,SL);
    }
    }
    else if (Position.MarketPosition==MarketPosition.Long)
    {
    if (Close[0]<EMA(Slow)[0])
    ExitLong(1);

    }
    else
    {
    if (Close[0]>EMA(Slow)[0])
    ExitShort(1);
    }
    I would like to enter the short trade when the condition is met.

    Please advise.

    Rajesh

    #2
    Hello RajeshT,

    Thank you for the post.

    Is the condition becoming true? From what you provided that seems to be correct, I woudld likely suggest to use a Print here to see if the condition is ever true. You could also enable TraceOrders to see if other errors are happening.

    Code:
    if (CrossBelow(EMA(Fast), EMA(Slow), 1))
    {
    [B]Print("Here");[/B]
    EnterShort(1);
    SetStopLoss(CalculationMode.Ticks,SL);
    }


    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse,

      Looks like it has to do with the StartBehavior and Market condition statements that are causing the discrepancy in putting the long and short entry. What are the appropriate statements for a typical short and long entry. Please advise.

      Thanks

      Rajesh

      Comment


        #4
        Hello RajeshT,

        Thank you for the added details.

        Are you asking what the typical syntax is for market type orders? I would otherwise not be certain of a typical entry, that would relate to the condition you build and what your goals are.

        If the condition or start behavior are related to what you are seeing you may need to review those items in the help guide to gain more perspective about the options being used in contrast to the conditions you made. https://ninjatrader.com/support/help..._positions.htm

        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by abelsheila, 05-14-2025, 07:38 PM
        2 responses
        33 views
        0 likes
        Last Post hglover945  
        Started by nailz420, 05-14-2025, 09:14 AM
        1 response
        72 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
        0 responses
        352 views
        1 like
        Last Post NinjaTrader_Brett  
        Started by domjabs, 05-12-2025, 01:55 PM
        2 responses
        66 views
        0 likes
        Last Post domjabs
        by domjabs
         
        Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
        1 response
        87 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X