NexusFi: Find Your Edge


Home Menu

 





Need help to see what's wrong with my code


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one kingfish88 with 2 posts (0 thanks)
    2. looks_two growex with 2 posts (5 thanks)
    3. looks_3 rmejia with 1 posts (2 thanks)
    4. looks_4 Nicolas11 with 1 posts (0 thanks)
    1. trending_up 1,841 views
    2. thumb_up 7 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Need help to see what's wrong with my code

  #1 (permalink)
 kingfish88 
Las Vegas
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-Fire
Trading: ES
Posts: 14 since Jun 2009
Thanks Given: 66
Thanks Received: 2

Sorry I'm new to Thinkscript.

I'm try to plot a arrow on every 4 consecutive down day (close to close), and 5 consecutive up day.

===
Plot Down4Day = close < close[-1] and close[-1] < close[-2]
and close[-2] < close[-3]
and close[-3] < close[-4]
;

Down4Day.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);

Plot Up5Day = close > close[-1] and close[-1] > close[-2]
and close[-2] > close[-3]
and close[-3] > close[-4]
and close[-4] > close[-5]
;

Up5Day.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_Down);

====

but after I apply this code to a chart, the arrows are no where near what it should be. Anything would be helpful!!!

Thanks in advance!!!

Wes

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
 
  #2 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441

The period number without the negative looks back:

 
Code
Plot Down4Day = close < close[1] and close[1] < close[2] and close[2] < close[3] and close[3] < close[4];
Down4Day.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
Down4Day.SetDefaultColor(Color.GREEN);



Plot Up5Day = close > close[1] and close[1] > close[2] and close[2] > close[3] and close[3] > close[4] and close[4] > close[5];
Up5Day.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_Down);
Up5Day.SetDefaultColor(Color.Red);

Reply With Quote
Thanked by:
  #3 (permalink)
 kingfish88 
Las Vegas
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-Fire
Trading: ES
Posts: 14 since Jun 2009
Thanks Given: 66
Thanks Received: 2


Cool. Thx!

Follow me on Twitter Started this thread Reply With Quote
  #4 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79

Consecutive equal conditions can be optimized by sum function for example the two following conditions returns equal results::

1. sum(close>close[1],3) == 3

2. close>close[1] and close[1]>close[2] and close[2]>close[3]

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

Hi,

The "sum" instructions is shorter (in number of characters) but I think that it is slower (in execution time).

It requires three evaluations of the condition whereas the "and" is supposed to return FALSE if the first condition is FALSE, without evaluating the two others.

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79

Yes, Nicolas, it sure is. This is just an example of using boolean return in mathematical operations
I've seen alot of studies with statements like:
def c = if a>b then 1 else 0;
actually there is no need to assign 1 or 0 such way, the optimized equation would be simply
def c = a>b;

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on January 7, 2014


© 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