Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators Crossing Price Bars

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

    Indicators Crossing Price Bars

    I have a strategy that enters a long market order when the 10 EMA crosses the price bar with the 20 below it and enters a short market order when there's a 10 cross with the 20 EMA above it.
    In backtesting (NT 7), the trade is not always consummated, although it of course always happens in the real world. I use GetCurrentBid as the bar price for buy orders and GetCurrentAsk as the sell price for sell orders. I don't care if the EMA crosses the Bid, the Ask, or the Last, as long as it crosses some part of the price bar. It would seem to me that using the bid price on a buy and the ask price on a sell would capture the cross no matter where in the bar it occurred.
    I was wondering if I'm coding this wrong or if my problem is a function of the backtest engine. This is being tested on an intraday range chart.
    Here is relevant code:
    if (EMA(10)[0] > EMA(20)[0]
    && GetCurrentBid()<= EMA(10)[0])
    {
    EnterLong(DefaultQuantity, "10Long");
    }
    Last edited by sgordet; 01-07-2011, 04:05 PM.

    #2
    Hello sgordet,

    Your description for what you're looking for does not match the code.

    enters a long market order when the 10 EMA crosses the price bar with the 20 below
    There's no CrossBelow statement there. You're only checking if one period ema is less than another, and if Close (GetCurrentBid() in a backtest) is less than or equal to 10 period ema.

    If you're looking for cross below conditions, use CrossBelow() method for this. You can also define these in the strategy wizard condition builder.

    You should also be aware of the debugging tools available. You'll want to use TraceOrders to track order submission for strategies, and print statement to track values of your variables. Help for using these debugging tools is available here:
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by giogio1, Today, 12:52 AM
    0 responses
    9 views
    0 likes
    Last Post giogio1
    by giogio1
     
    Started by butt_toast, 04-28-2021, 05:46 AM
    8 responses
    2,714 views
    0 likes
    Last Post ILSNT
    by ILSNT
     
    Started by vingyhomg, Yesterday, 11:35 PM
    0 responses
    8 views
    0 likes
    Last Post vingyhomg  
    Started by brucerobinson, 04-21-2025, 12:14 PM
    4 responses
    34 views
    0 likes
    Last Post brucerobinson  
    Started by M_ichel, Yesterday, 02:21 PM
    1 response
    13 views
    1 like
    Last Post brucerobinson  
    Working...
    X