NexusFi: Find Your Edge


Home Menu

 





BarsSinceExit


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Dvdkite with 3 posts (1 thanks)
    2. looks_two ABCTG with 2 posts (0 thanks)
    3. looks_3 bobwest with 2 posts (0 thanks)
    4. looks_4 SMCJB with 2 posts (3 thanks)
    1. trending_up 3,506 views
    2. thumb_up 4 thanks given
    3. group 5 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

BarsSinceExit

  #1 (permalink)
jessehhhh
Montclair
 
Posts: 17 since Nov 2018
Thanks Given: 0
Thanks Received: 0

Hi All,

In my strategy I want to add a clause that doesn't allow the same strategy to enter until 1 bar after an exit has occurred. What I have come up with is this but it isn't working.

If (barssinceexit>1 or Total Trades<1) then {strategy}. If anyone can clarify why this isn't working please let me know and thank you in advance.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


jessehhhh,

what do you mean by "it isn't working", what is happening exactly? Can you post code that can be used to reproduce what you are seeing?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
jessehhhh
Montclair
 
Posts: 17 since Nov 2018
Thanks Given: 0
Thanks Received: 0

ABCTG,

I mean when I used the code

If (barssinceexit>1 or totaltrades<1) then

begin...

On my chart it still shows a trade beginning in the same bar that a previous trade exited from the same strategy.

Reply With Quote
  #5 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,386
Thanks Received: 10,206

I don't use barssinceexit but I know that barssinceentry doesn't update till the next bar.

You could track the position

MP = marketposition;
If (MP=0 and MP[1]=0) then begin...

Reply With Quote
Thanked by:
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

jessehhhh,

I would suggest using the print reserved word to check the value the reserved words hold within your code.
Like @SMCJB mentioned they might only get updated at the end of the bar and you could act on "old" information.

Regards,

ABCTG


jessehhhh View Post
ABCTG,

I mean when I used the code

If (barssinceexit>1 or totaltrades<1) then

begin...

On my chart it still shows a trade beginning in the same bar that a previous trade exited from the same strategy.


Follow me on Twitter Reply With Quote
  #7 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


SMCJB View Post
I don't use barssinceexit but I know that barssinceentry doesn't update till the next bar.

You could track the position

MP = marketposition;
If (MP=0 and MP[1]=0) then begin...

Hello SMCJB,

I was just searching for a solution because I have the same problem with barsinceexit(1) and MULTICHARTS. I'm not able to make it work ..

So I tryed you solution by checking the position by using this code:

 
Code
if marketposition = 0 and marketposition[1] = 0 and marketposition[2] = 0 then begin
but it doesn't work!! I can still see on a 15 minutes bar chart 2 consecutive trades , one in a bar and another in the following bar. How's that possible?
is marketposition[1] referring only the the effective market position at the end of a bar? because the first trade has been filled and close INSIDE a 15 minutes bar so at the end of the bar the marketposition is AGAIN zero.

What do you think?

Thanks

David

Reply With Quote
  #8 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,386
Thanks Received: 10,206

I don't think you can use marketposition[1], it isn't a variable like that, hence the need for MP = marketposition and then use MP[1]

Reply With Quote
Thanked by:
  #9 (permalink)
 
bobwest's Avatar
 bobwest 
Western Florida
Site Moderator
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES, YM
Frequency: Several times daily
Duration: Minutes
Posts: 8,168 since Jan 2013
Thanks Given: 57,452
Thanks Received: 26,278

Hi @Dvdkite,

I don't have an answer to your questions about barsinceexit, but I've noticed that you have opened a couple of threads with "barsinceexit(1)" in the title. There seems to be an issue with threads titled this way, which makes them not accessible. There is no issue with just plain "barsinceexit" without the "(1)" -- if you wonder why you're not getting many replies to those posts, this is the reason.

For instance, this thread is fine, and it uses "barsinceexit" alone.

So if you want to post your question, please just refer to "barsinceexit" by itself in the thread title, leaving off the "(1)".

I hope you find your answer.

Bob.

When one door closes, another opens.
-- Cervantes, Don Quixote
Reply With Quote
  #10 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25



SMCJB View Post
I don't think you can use marketposition[1], it isn't a variable like that, hence the need for MP = marketposition and then use MP[1]

Thanks for the suggestion but it doesn't work also using your suggestion... (I'm using multicharts).. I'm struggling to avoid consecutive entries and I cannot make it work...

Reply With Quote




Last Updated on November 25, 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