Hi,

I'm testing a simple strategy with daily bars. Enter long if today's high is the highest in 20 days, and exit long if today's low is the lowest in 50 days. I want the order and fill prices are the price at the moment when the crossing happens in the day. I tried to use TradePriceOpen and TradePriceClose to set the order price, but the printed TradePriceClose and TradePriceOpen are not the cross level as expected. So are they supposed to use to set the order and fill prices? If not, how to set the order and fill prices? Thanks!

Code
    if (NumOpenLong > 0)   // long position
    {
        if (priceLow() < LL(50-1, 1))  // exit triggered
            {
                TradePriceClose = LL(50-1, 1);
                printf(" Exit Long low=%f order_price=%f ", priceLow(), TradePriceClose);
                exitLong();
                printf(" TradeLots=%d NumOpenLong=%d", TradeLots, NumOpenLong);
            }
    }
    else  if (priceHigh() > HH(20-1, 1))  // entry long triggered
    {
            TradePriceOpen = HH(20-1, 1);
            printf(" Enter Long high=%f order_price=%f q_order=%d", priceHigh(), TradePriceOpen, q_order);
            enterLong(q_order);
            printf(" TradeLots=%d NumOpenLong=%d", TradeLots, NumOpenLong);
    }

Last edited by JesseL; 07/02/19 06:08.