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 rhyminkevin, Today, 04:58 PM
    3 responses
    47 views
    0 likes
    Last Post Anfedport  
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    50 views
    0 likes
    Last Post futtrader  
    Working...
    X