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)
I am in the process of writing a strategy using Flex Renko bars. One of my challenges is that at the end of the day, I want to close out any open positions at 4:05 PM EST. Well because of the nature of a renko bar, any given renko bar can take an unknown amount of time to complete as time has no function in the formation of a renko bar. That is the problem.
So my strategy works great except for the end of day. I figure the only way to combat this problem is to run the strategy on a intrabar basis. So, given that I often use the barstatus, I can instruct most of the program to test at the end of each bar. Moreover, I use functions early and often. I find that it's easier for me to troubleshoot problems if I break my strategy into functions and use the strategy as the general flowchart and direct it to functions based on basic logical tests.
So in the beginning of my strategy, I have a function that calculates trading sessions as well as times where it's ok to enter into trades. Of course, when the trading session ends, the strategy would exit any open positions.
So... can I use the reserve word IntraBarOrderGeneration in a function? If so, is there anything I need to be mindful of when coding. I did see somewhere where this RW is only applicable to strategies. Does this mean I can't use it in functions???
EDIT: Let me ask you this. If I call on the function on a tick by tick basis (by not waiting for Barstatus = 2) then the function will cycle each and every tick, correct? If so, then I really don't need to worry about this RW right? Please clarify. Thanks
Thanks for the help
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
the IntraBarOrderGeneration attribute is used for strategies. You do not need this in a function as the frequency of its computation depends on the calling code.
Having said that, you can call a function with every tick.
I would suggest testing this with a simple test code.
OK, so the message I got when I tried it on a function was "This attribute can be applied only for variables"
Then I realized that I tried using it on input values. So basically if I understand one of your previous posts, it the function is called in the middle of the bar because the strat is operating on a tick by tick basis, the function should make the evaluation using the current information, correct?
sounds correct. For functions you do not set the IntraBarOrderGeneration attribute, the frequency of the function being called is determined by the calling code. If you need the function's variables to be updated with every tick, they need to be intrabarpersist, though.
I managed to put together a strategy that layers in and out successfully. My only problem seemed to be that because I am using a FLEX RENKO chart, by using a strat that tests at the end of each bar, my end of day code may leave the position open because the bar didn't close before the session ended.
So... I decided to use [IntraBarOrderGeneration = True] and run the strat with Barstatus = 2 for all but the end of day check which is tick by tick. When I did this... my layers will not close right anymore. WHY?
Just to check things out... as a test, I pasted "[IntraBarOrderGeneration = True]" to a previous version of the strat and compiled it and sure enough, the layers didn't close there either. HOWEVER, when I deleted that statement and re-compiled, the layers remain unclosed as if the statement was still there.
EDIT: I tried one more thing... I deleted the test previous strat from the chart, then reinstalled it and it's back to working correctly again. So again I ask... why would this act this way? What is it about IBOG that messes up my layers closing correctly?
WTF??? Please let me know what I'm doing wrong. Thanks