NexusFi: Find Your Edge


Home Menu

 





Help with Barstatus using Renko


Discussion in EasyLanguage Programming

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




 
Search this Thread

Help with Barstatus using Renko

  #1 (permalink)
 GuppyDRV 
Seattle
 
Experience: Intermediate
Platform: MultiCharts 10
Broker: InteractiveBrokers, IQFeed
Trading: ES
Posts: 58 since Nov 2015
Thanks Given: 19
Thanks Received: 7

Hello all,

I know.....I know Renko! I’ve been using them for years with manual trading and have been trying to creat some automated signals based on the indicators that I use visually.

The basic setup although the time period and points are random. I’ve tried different settings but get the same results.

Multi Chart 11
3 Minute Renko
2 point bars
No Phantom bars
No show real open
brake on session
trade RTH ES


The problem is two fold and requires a bit of an explanation.

First: As we all know Renko bars are price based and not time based although they have a time component. This time component is the measurement period whereby the bar decides if the point range has been exceeded thus causing a new bar to be formed. In this example at 3 minute intervals the bar performs a check and can either close and form a new bar or continue on with this loop. I’m finding that my strategy is closing on the first iteration of the time loop regardless of how long the bar is in existence. So let’s say that my 3 minute bar takes 30 minutes to exceed the 2 point range and form a new bar my strategy fires at the end of the first 3 minute period leaving 27 more minutes until actual bar close. When bars are formed at the end of the first 3 minute period things perform as expected on the close of that bar. It’s only when a bar goes beyond the first 3 minute period that I have problems.

This seems to indicate that the Barstatus check is not happening successfully. I’ve tried several variations on the code but none work. Am I missing an additional programming step?

Secondly: When the strategy is applied to a historical chart the trades on the historical chart happen exactly one bar prior to where they happened in real time. I’m stumped as to why! I would prefer to actually have the strategy trade as it backtest but backtesting the way it trades would also allow for an accurate historical evaluation as well. I’m not able to figure out why there is a difference. Outside of a coding error are there system/chart settings that might effect backtest trade placement verse live trading?

This is a sample of the code logic I’m using with the Barstatus check:

 
Code
If timeFilter and marketposition = 0 then 
begin
​If barstatus(1)= 2 then 
begin
​​
​If (Stratagey Logic Here) then 
begin
​sellshort ("Short1") 1 contracts this bar on Close; //needed for backtest with Renko
​end;
​end;
end;

If marketposition = -1 then 
begin
​If barstatus(1)= 2 then 
begin
​
​If (Stratagey Logic Here) then 
begin
​buytocover ("E1") from entry ("Short1") 1 contracts this bar on Close;
​end;
​end;
end;

Thanks everyone for some much needed help!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Futures True Range Report
The Elite Circle
Exit Strategy
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


GuppyDRV,

when using "this bar on Close" in a strategy you will introduce a different behavior between real time and historical results. This happens simply due to the fact that in real time at the moment the platform can know a bar is closed any order issued at that point will get filled around the open of the next bar.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 GuppyDRV 
Seattle
 
Experience: Intermediate
Platform: MultiCharts 10
Broker: InteractiveBrokers, IQFeed
Trading: ES
Posts: 58 since Nov 2015
Thanks Given: 19
Thanks Received: 7

@ABCTG

I’m copying @mattyham as he seems to have some similar questions.

Thanks so much for the reply. After observing the bars in live action and doing some thinking on the topic I have some observations to report and a solution if possible.

So here it goes:

When using a single data series with chart type Renko and in live trading the trades happen when one would expect and at the correct price but only if Automation has been turned on. With Automation off and using the (buy next bar at market) logic the trades will happen at the open price of the bar which generated the signal or the close price of the bar prior if using (buy this bar on close). Sounds confusing I know but let me explain.

The Renko Bar time stamp is always the open time of the bar. This time will reset mid bar if the Renko logic fails to signal a close thus resetting the timer. The end time of any closed Renko Bar is always the open time of the last timer iteration prior to the iteration that closes the bar. Clear as mud?

I’ll try and walk through it with an example that can be observed. First some setup information. Let’s still use the 3 minutes bar example but this time will build an underlying Ask/Bid series that we will have visible in panels two and three of the same chart screen (will do this visually so that we can observe what price Multicharts is using in backtest). These will be data 2 and data 3 with data 1 being the Renko Bar chart. This of course is the setup for precise backtesting but will also allow us to visualize the trades.

In this example we will live trade the strategy on a chart with just data 1 as Renko bars for the sole purpose of determining when in time actual live trades take place. As stated above without Automation on we will not get true trades or pricing nor will we have a record. We will use Automation which will create a record in the order window that we can reference at days end that reflects actual live results. This strategy will use the (next bar at market) logic.

At days end we will open a second instance of Multicharts and load the workspace with the three data series as described above. Apply a version of the strategy with the same settings except this will use the (this bar on close) logic. It’s now possible to clearly see that the Bar time of the bar generating the trade is exactly 3 minutes off the actual trade time thus explaining why in my initial post I was observing all trades being one bar late.

(Side note....I print out my code so that I can see when and where all things happen but you can still do this visually without).

So if the live trade happened at 12:00 the Bar time of the closed Renko Bar will be 11:57 assuming in this example that the bar closed after one time iteration. In backtest Multicharts will go to the close of the 11:57 bar of data 2/3 depending on if buying or selling and use this price. So one bar early and obviously the wrong price. The actual backtest trade should happen at the close of the 12:00 bar which would closely approximate how we traded live.

If in this example we were to use the (next bar at market) logic Multicharts would grab the open price of the 12:00 bar rather than the open of the 12:03 bar which again would be wrong.

My clunky work around was to recode a backtest version of my strategy which induced a one bar delay in actuating the trades. With this setup I’m now taking the trade on the close of the 12:00 bar giving me a more accurate representation. This is a very time consuming exercise and not completely accurate. I haven’t had a chance to debug this first pass and have some errors. I’m also not 100% certain this will be accurate as I’m still debugging this workaround.

So here goes the big question, assuming I fumbled my way through an explanation that you were able to follow. If we use the Resolution Manager to crack open the code of the Flex Renko is it possible to have the Bar time stamp show the close of the bar (like a normal candle stick) rather than the open? After much thought I’m convinced it wouldn’t effect bar performance other than showing a different time. Effectively, this would allow for exact backtest using the Renko when paired with an Ask/Bid series.

I’m not versed in C so doing this myself is beyond my ability. Any thoughts would be greatly appreciated.

GuppyDRV

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

GuppyDRV,

I am not sure if a custom resolution would be the way to go as you might have a lot more control by recreating the bar logic internally within the code out of underlying 1 tick data. The benefits with that approach would be that you could use the bar magnifier for your back testing, too. This will however not be a trivial task and take a bit of coding - however this would be in Powerlanguage and wouldn't require you to become familiar with C# first.

For your questions on the custom resolutions I would suggest contacting the MC support directly.

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on October 2, 2019


© 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