NexusFi: Find Your Edge


Home Menu

 





tried to reference too many bars back


Discussion in TradeStation

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




 
Search this Thread

tried to reference too many bars back

  #1 (permalink)
 
malibu's Avatar
 malibu 
toronto canada
 
Experience: Advanced
Platform: Matlab + NT + TS
Trading: FOREX
Posts: 65 since Jul 2013
Thanks Given: 9
Thanks Received: 17

Hey folks,
For the life of me, I can NOT get the following strategy to place a trade. The code will verify, but when I open the strategy I get the error -tried to reference too many bars back- I then go to format strategy and change max bars back to 500... the strategy then runs but places no trades... please help.


inputs:
Price(Close),
small_trigger_period(20),
multiplier(4),
upcolor(Green),
downcolor(Red),
large_trigger_period(80);



Vars:
oLRSlope(0),ema(0), oLRAngle(0), oLRIntercept(0), oLRValueRaw(0),LowerBand( 0 );


Value1 = LinearReg (price, small_trigger_period, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value2 = oLRValueRaw;
Value3 = XAverage(Value2,5);



Value11 = LinearReg (price, large_trigger_period, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value12 = oLRValueRaw;
Value13 = XAverage(Value2,large_trigger_period/multiplier);



if {Value2>Value3} {and} Value12 crosses over Value13 then
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
Buy ( "BBandLE" ) next bar at market ;


{if Value1 crosses under Value2 and Value11 crosses under Value12 then
Sell ( "CustomLX" ) next bar at market ;
}

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

malibu,

it works fine for me. As you have blocked the short entries the strategy will only enter long, so you will only find one entry somewhere close to the beginning of the chart (max bars back setting plus a couple of bars).

Regards,
ABCTG


malibu View Post
Hey folks,
For the life of me, I can NOT get the following strategy to place a trade. The code will verify, but when I open the strategy I get the error -tried to reference too many bars back- I then go to format strategy and change max bars back to 500... the strategy then runs but places no trades... please help.


inputs:
Price(Close),
small_trigger_period(20),
multiplier(4),
upcolor(Green),
downcolor(Red),
large_trigger_period(80);



Vars:
oLRSlope(0),ema(0), oLRAngle(0), oLRIntercept(0), oLRValueRaw(0),LowerBand( 0 );


Value1 = LinearReg (price, small_trigger_period, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value2 = oLRValueRaw;
Value3 = XAverage(Value2,5);



Value11 = LinearReg (price, large_trigger_period, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value12 = oLRValueRaw;
Value13 = XAverage(Value2,large_trigger_period/multiplier);



if {Value2>Value3} {and} Value12 crosses over Value13 then
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
Buy ( "BBandLE" ) next bar at market ;


{if Value1 crosses under Value2 and Value11 crosses under Value12 then
Sell ( "CustomLX" ) next bar at market ;
}


Follow me on Twitter Reply With Quote
  #3 (permalink)
 
malibu's Avatar
 malibu 
toronto canada
 
Experience: Advanced
Platform: Matlab + NT + TS
Trading: FOREX
Posts: 65 since Jul 2013
Thanks Given: 9
Thanks Received: 17



ABCTG View Post
malibu,

it works fine for me. As you have blocked the short entries the strategy will only enter long, so you will only find one entry somewhere close to the beginning of the chart (max bars back setting plus a couple of bars).

Regards,
ABCTG

Thank you so much! For some reason I am not understanding the max bars back deal or something because I can't get this thing to place a long trade at all... further assistance will be greatly appreciated.

Started this thread Reply With Quote
  #4 (permalink)
 
malibu's Avatar
 malibu 
toronto canada
 
Experience: Advanced
Platform: Matlab + NT + TS
Trading: FOREX
Posts: 65 since Jul 2013
Thanks Given: 9
Thanks Received: 17

This one gives me the max bars back error, and again generates no trades... I'm missing something simple I think





inputs:
Price(Close),
small_trigger_period(20),
multiplier(4),
upcolor(Green),
downcolor(Red),
large_trigger_period(80);



Vars:
oLRSlope(0),ema(0), oLRAngle(0), oLRIntercept(0), oLRValueRaw(0),LowerBand( 0 );


Value1 = LinearReg (price, small_trigger_period, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value2 = oLRValueRaw;
Value3 = XAverage(Value2,5);



Value11 = LinearReg (price, large_trigger_period, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value12 = oLRValueRaw;
Value13 = XAverage(Value2,large_trigger_period/multiplier);



If Value2>Value3 AND Value12>Value13 then
Begin
Buy ( "Long" ) 100000 shares next bar at market ;
End;




If Value2<Value3 AND Value12 < Value13 then
Begin
Sellshort ( "Short" ) 100000 shares next bar at market ;
End;

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

The issue with max bars back is in fact quite simple once you got the hang out of it. You set how many bars you want be on the chart before the strategy can compute properly. It's a pain that you have to do it manually, but that's the way it is.
So when you have an average within your strategy that has a length of 80, you will have to set a Max Bars back value of at least 80. As an average with the length of 80 needs 80 bars to be calculated properly. Otherwise the strategy will trigger an error.

I suppose you didn't see any trades on your charts, because the Max Bars Back setting was very high and your amount of bars on the chart was very little (maybe even less than the Max Bars Back input). What interval and symbol did you use?

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #6 (permalink)
 Captain135 
Bay Area, CA
 
Experience: Intermediate
Platform: TradeStation, TOS
Trading: Futures, Equities, Options on Futures
Posts: 48 since Feb 2017
Thanks Given: 53
Thanks Received: 30


ABCTG View Post
The issue with max bars back is in fact quite simple once you got the hang out of it. You set how many bars you want be on the chart before the strategy can compute properly. It's a pain that you have to do it manually, but that's the way it is.
So when you have an average within your strategy that has a length of 80, you will have to set a Max Bars back value of at least 80. As an average with the length of 80 needs 80 bars to be calculated properly. Otherwise the strategy will trigger an error.

Everything you describe makes it sound like the function should actually be called minimum bars back. Would you agree that the practical use of "max bars back" is to ensure the minimum, not maximum, number of bars required?

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

Captain135 ,

the practical use is to ensure that all calculations within your code have enough bars to be computed correctly. If it helps your understanding you can consider this as the absolute minimum number of bars required to achieve that. It might also help to understand the term "Maximum number of bars study will reference" as the "Maximum number of bars a calculation within your study will look back at previous bar's values". However, there is another point to keep in mind here and I have addressed this in my last webinar I did with nexusfi.com: For calculations with starting point dependencies like an exponential average for example this setting allows you to control how many bars you give the code to "swing in" in order for you to be able to reproduce and compare results and not to have the results change simply due to a different starting point.

Regards,

ABCTG



Captain135 View Post
Everything you describe makes it sound like the function should actually be called minimum bars back. Would you agree that the practical use of "max bars back" is to ensure the minimum, not maximum, number of bars required?


Follow me on Twitter Reply With Quote




Last Updated on May 12, 2020


© 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