Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
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 -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated May 4, 2020
trending_up
1,529 views
thumb_up
1 thanks given
group
3 followers
forum
6 posts
attach_file
0 attachments
April 24th, 2020, 12:48 PM
Dresden + Germany
Posts: 21 since Feb 2018
Thanks Given: 11
Thanks Received: 5
Hello to the Forum,
I would like to ask for your assistance with the following question.
I want to synchronize different filters that use boolean variables.
For this I have to move a true condition to the previous bar.
Example: A condition becomes true at bar x,y,z.
How can I set the condition at the previous bar x-1,y-1,z-1 to true.
Thank you very much for your support and stay healthy!
user10
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
April 26th, 2020, 07:37 AM
Dresden, Germany
Posts: 3 since Apr 2020
Thanks Given: 1
Thanks Received: 0
Hey user10,
you can use
CurrentBar - BarsAgo = index of bar
In your case, this means
CurrentBar - 1 = previous bar
Best regards from near Dresden
Martin
April 27th, 2020, 09:24 AM
Dresden + Germany
Posts: 21 since Feb 2018
Thanks Given: 11
Thanks Received: 5
Hello Martin,
Thank you for the advice.
My problem is more complex.
In the history I calculate different filters which have to be synchronized.
By means of a list I get the respective beginning of a true condition.
This condition entry should now be moved one bar into the past.
All attempts to achieve this with currentbar have failed.
This makes sense, because the respective calculation only takes place at the current bar...
In my understanding I have to use a programming that calculates backwards at the last historical bar and then sets the condition to true at the previous bar.
I did not succeed with an array or a list.
Do you have an idea how I can solve the problem?
Thanks a lot
user10
PS: Grüße nach Sachsen
April 29th, 2020, 03:21 PM
Dresden, Germany
Posts: 3 since Apr 2020
Thanks Given: 1
Thanks Received: 0
Hey User10,
do you have a concrete example for me?
We will find a solution for this!
April 29th, 2020, 05:21 PM
Dresden + Germany
Posts: 21 since Feb 2018
Thanks Given: 11
Thanks Received: 5
Hello Martin,
The goal is to move the condition one bar to the left.
I can't do this with the approach BarsAgo or with a list that displays the previous bar.
What am I doing wrong?
Regards
user10
Code
protected override void OnBarUpdate ()
{
if ( BarsInProgress != 0 ) return;
if ( CurrentBars [ 0 ] < 1 ) return;
// Test BarsAgo
myCond = CrossAbove ( SMA1 , SMA2 , 1 ) ? true : false ;
if ( myCond ) Draw . VerticalLine ( this , "myCond" + CurrentBar , 0 , Brushes . Red , DashStyleHelper . Solid , 3 );
if ( myCond ) myCondPrevSeries [ 1 ] = true ; // does not work ==> same result as myCond
if (! myCond ) myCondPrevSeries [ 1 ] = false ;
// if (myCondPrevSeries[1]) Draw.VerticalLine(this, "myPrevCond"+ CurrentBar, 0, Brushes.Black, DashStyleHelper.Solid, 3);
// Test List
if ( myCond ) { myList . Add ( CurrentBar );}
for ( int i = 0 ; i < myList . Count ; i ++)
{
previousEventCounter = myList [ i ] - 1 ; // returns PreviousBar
if ( Bars . IsLastBarOfSession ) Print ( "Event # " + i + " Occured on bar: " + myList [ i ] + " previousEventCounter " + previousEventCounter );
}
myListCond = ( CurrentBar == previousEventCounter ) ? true : false ; // will never reach this value?
// if (myListCond) Draw.VerticalLine(this, "myListCond"+ CurrentBar, 0, Brushes.Cyan, DashStyleHelper.Solid, 3);
Print ( Time [ 0 ]
+ " Try BarsAgo "
+ " myCond " + myCond
+ " myCondPrevSeries[1] " + myCondPrevSeries [ 1 ]
+ " Try List"
+ " CurrentBar " + CurrentBar
+ " previousEventCounter " + previousEventCounter );
}
May 2nd, 2020, 01:09 PM
Berlin, Europe
Market Wizard
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,889 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,107
user10
Hello to the Forum,
I would like to ask for your assistance with the following question.
I want to synchronize different filters that use boolean variables.
For this I have to move a true condition to the previous bar.
Example: A condition becomes true at bar x,y,z.
How can I set the condition at the previous bar x-1,y-1,z-1 to true.
Thank you very much for your support and stay healthy!
user10
Use a Series<bool> and set the value to the bars x-1, y-1 and z-1. This series can be handled in the same way as a Series<double>.
May 4th, 2020, 09:38 AM
Dresden + Germany
Posts: 21 since Feb 2018
Thanks Given: 11
Thanks Received: 5
Hello, Fat Tails,
thank you very much for your hint!
I have been trying to solve the problem for a few days now.
How do I assign a value to the previous bar?
Using a boolean series does not work; in my example I had formulated this.
What am I doing wrong?
According to my understanding I can't work with currentBar == previousEventCounter ==> this value will never be reached.
I am currently working on a solution with a for loop that counts backwards. I have no success with that either.
I am grateful for any support.
Thanks a lot and stay healthy!
user10
Last Updated on May 4, 2020