Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Got a problem with my current strategy setup.
I have an indicator that effectively needs to calculate at the end of bar close. Therefore the strategy is set to calculate @ close.
However I have set up a method of when the indicator triggers, an entry order is placed 1 tick - the current bar's close (buy.) A cancel order is set to trigger if the price moves 3 ticks + the current order.
However because the strategy is set to calculate @ close, there has been repeated times where an order has been placed, then the price moving 4 -5 ticks with being filled. (ie the bar has not closed.)
How is it possible to for the order to be calculated tick for tick?
I heard of using OnMarketData but have no idea how to code it?
Any help would be great. Thanks
Can you help answer these questions from other members on NexusFi?
My only suggestion is to use CalculateOnBarClose = False, which will fix your cancel code and then use "FirstTickOfBar" in your entry code. When doing that, set your signal back one bar. So, instead of:
if (CrossAbove(EMA(20), EMA(50), 0)), use:
if (FirstTickOfBar && CrossAbove(EMA(20), EMA(50), 1))
This allows your signal to reach bar close before entering. There may be a better way out there but I THINK this will do what you want.
I hear you as I like to let the bar close before entering as well but this can be used as a fix. When you add FirstTickOfBar to your entry code and set your signal back a bar, it basically tells you strat to wait until your entry bar closes (like you want) and then enter at the first tick of the next bar. I then set my entry order to Open[0]. So, for the example I gave you, at the open of the current bar, the strat would check to see if the 20 crossed above the 50 on the close of the last bar. If it did, it would enter. Using this combo prevents the strat from taking trades mid-bar.
Unless I'm missing something (or too hungover to fully understand you), I think this will do it.
Hmm....every indicator in your code SHOULD require you to decide which bar to choose ([0] being current, [1] being one bar back). Basically, if you see a [0], try changing it to [1]. If your signal isn't secret, I'd be happy to have a look. Otherwise, let's start with that.
hmm well its a custom indicator off a vendor. I have tried to use [1] but doesnt seem to work. When I set to calc at close to false, it becomes way too CPU intensive.
Is it possible to have 2 strategies running?
ie - One for the indicator, and the other being for order placement and trade management?
I don't think that's possible but there are many people much more experienced with programming than I am. Maybe they know better. Is your indicator a free one? If so, I'll download and try and figure out the code. If not, maybe you can post or PM me the part that only includes the numbers? Sometimes, you don't get [0] but can have "(xxx, 0)" instead.