Enter on CalOnBarClose=True, but Exit Immediately on X Ticks | Traders Hideout


futures.io - futures trading strategies, market news, trading charts and platforms


Traders Hideout


Discuss day trading practices and futures trading strategies on this forum for all markets. This forum is also for discussing and reviews for brokers, data feeds, and commercial or third party add-ons




 

Enter on CalOnBarClose=True, but Exit Immediately on X Ticks

  #8 (permalink)

Los Angeles CA
 
Trading Experience: Advanced
Platform: NT
Favorite Futures: ES
 
Posts: 11 since Aug 2015
Thanks: 3 given, 5 received

Thanks - I have both a stop and a PT resting on my broker's servers. However, in one of my long "BTD" strategies, if the price climbs up at least 12 ticks on my entry bar only, I'd like to exit my position prior to my entry bar closing.

I'm aware I can set to false CalcOnBarClose, but I'd like to keep that as true. I could set multiple profit targets, but that comes at the cost of not letting certain winners run. The issue I'm trying to solve is the occurrence where the price goes strongly(ie at least 12 ticks) in your favor on your entry bar, and you want to lock in those gains before the inevitable drop.


spinnybobo View Post
Hey
so if I understand you correctly you have a strategy and you are in a position and want to exit BEFORE the bar closes.

So is your logic when it goes in your favor by 12 ticks? Are you using either stops or targets or both?
Tell me the logic of your strategy.
If you want to backtest it Historically you need to layer in 1 tick data like this

 
Code
protected override void Initialize()
{
     CalculateOnBarClose = true;
     Add(PeriodType.Tick, 1);  
     // adding 1 tick data to the chart which will make it load slowly so only add no more than 5 days
}
Otherwise you can use OnMarketData which is not historical just real time ticks
You would want to use IOrders

if you are using stops and targets, you can set Target1 to 12 ticks and it will execute intrabar
lots of options depending on your logic.

 
Code
private IOrder entryOrder  = null;
private IOrder target1Order = null;
private IOrder stopOrder = null;

protected override void Initialize()
{
     Add(PeriodType.Tick, 1);  // BarsInProgress == 0 for base chart and 1 for ticks
     Unmanaged = true; // I always use unmanaged strategies because I prefer to cancel my stops and targets myself explicitly
}
protected override void OnBarUpdate()
{
     if (CurrentBars[0] > 3)
    {
        if (BarsInProgress == 0)
        {
            // base chart logic.  So if your using 15 min chart this happens every 15 minutes
        }
        if (BarsInProgress == 1)
       {
           // tick chart logic.  This chart you can't see but is synced with base chart and added in background
           
       }

    }
}
protected override void OnOrderUpdate(IOrder order)
{
    // handle setting stops and targets once the order is "order.Filled"
}


Reply With Quote