NexusFi: Find Your Edge


Home Menu

 





IntraBarOrderGeneration question with functions


Discussion in MultiCharts

Updated
    1. trending_up 3,369 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

IntraBarOrderGeneration question with functions

  #1 (permalink)
 
Sinatra Fan's Avatar
 Sinatra Fan 
Orlando FL
 
Experience: Intermediate
Platform: MultiCharts, Ninja
Trading: Emini ES
Posts: 66 since May 2019
Thanks Given: 7
Thanks Received: 9

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Request for MACD with option to use different MAs for fa …
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
55 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
What percentage per day is possible? [Poll]
31 thanks
GFIs1 1 DAX trade per day journal
29 thanks

  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Sinatra Fan,

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.

Regards,

ABCTG



Sinatra Fan View Post
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


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
  #3 (permalink)
 
Sinatra Fan's Avatar
 Sinatra Fan 
Orlando FL
 
Experience: Intermediate
Platform: MultiCharts, Ninja
Trading: Emini ES
Posts: 66 since May 2019
Thanks Given: 7
Thanks Received: 9


What about the RW "INTRABARPERSIST"???

Should I use this in a function?

EDIT... Just tried to use it and it seems that it won't compile.

Started this thread Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Sinatra Fan,

the reserved word "intrabarpersist" works fine in functions. Whether or not it is required in your code depends on your code logic.

Regards,

ABCTG


Sinatra Fan View Post
What about the RW "INTRABARPERSIST"???

Should I use this in a function?

EDIT... Just tried to use it and it seems that it won't compile.


Follow me on Twitter Reply With Quote
  #5 (permalink)
 
Sinatra Fan's Avatar
 Sinatra Fan 
Orlando FL
 
Experience: Intermediate
Platform: MultiCharts, Ninja
Trading: Emini ES
Posts: 66 since May 2019
Thanks Given: 7
Thanks Received: 9


ABCTG View Post
Sinatra Fan,

the reserved word "intrabarpersist" works fine in functions. Whether or not it is required in your code depends on your code logic.

Regards,

ABCTG

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?

Started this thread Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Sinatra Fan,

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.

Regards,

ABCTG


Sinatra Fan View Post
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?


Follow me on Twitter Reply With Quote
  #7 (permalink)
 
Sinatra Fan's Avatar
 Sinatra Fan 
Orlando FL
 
Experience: Intermediate
Platform: MultiCharts, Ninja
Trading: Emini ES
Posts: 66 since May 2019
Thanks Given: 7
Thanks Received: 9

OK, so I'm really getting frustrated.

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

Started this thread Reply With Quote





Last Updated on October 20, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts