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 agclub, Yesterday, 08:57 PM
    2 responses
    16 views
    0 likes
    Last Post agclub
    by agclub
     
    Started by cre8able, 04-17-2024, 04:16 PM
    6 responses
    55 views
    0 likes
    Last Post cre8able  
    Started by Mindset, 05-06-2023, 09:03 PM
    13 responses
    293 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by kaywai, 09-01-2023, 08:44 PM
    4 responses
    600 views
    0 likes
    Last Post joselube001  
    Started by dpolyakov, 03-29-2024, 11:30 AM
    3 responses
    135 views
    2 likes
    Last Post sonia0101  
    Working...
    X