NexusFi: Find Your Edge


Home Menu

 





how do i code the last n closes on a indicator?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ceramictilepro with 3 posts (0 thanks)
    2. looks_two Big Mike with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 cory with 1 posts (1 thanks)
    1. trending_up 1,614 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 2 attachments




 
Search this Thread

how do i code the last n closes on a indicator?

  #1 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21

Hello,

using a std stochastics indicator,

I am trying to create a code that will draw an arrow if:

 
Code
the last 8 closes of the stochastics are above 90
I am not looking for the last 8 closes of price just to be more clear.

Thank you for any help

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Futures True Range Report
The Elite Circle
Deepmoney LLM
Elite Quantitative GenAI/LLM
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537


I am a bit rusty, but I will try. I don't remember the Stochastic and DrawArrow overloads, but here is general idea

bool myArrowCondition = false;

if (Lowest(Stochastic(C, 1.618, 20), 8)[0] > 90) myArrowCondition = true;

if (myArrowCondition) DrawArrowUp(blah)

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21


Big Mike View Post
I am a bit rusty, but I will try. I don't remember the Stochastic and DrawArrow overloads, but here is general idea

bool myArrowCondition = false;

if (Lowest(Stochastic(C, 1.618, 20), 8)[0] > 90) myArrowCondition = true;

if (myArrowCondition) DrawArrowUp(blah)

Mike

is "Lowest" acceptable?
"lowest bar" is available but that is for price I believe.

getting an error with "Lowest"

 
Code
#region Variables
		  bool myArrowCondition = false;
 
Code
if (Lowest(aDoubleStochsdot(10),8).K[0] > 90) myArrowCondition = true;
			if (myArrowCondition)
			{
				DrawArrowDown("My down arrow2" + CurrentBar, false, 0, High[0] + 5 *TickSize, Color.Black);
			}
thank you

Started this thread Reply With Quote
  #5 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


ceramictilepro View Post
Hello,

using a std stochastics indicator,

I am trying to create a code that will draw an arrow if:

 
Code
the last 8 closes of the stochastics are above 90
I am not looking for the last 8 closes of price just to be more clear.

Thank you for any help

since you want to work with stoch the first thing you should do is making a copy of ninja stoch then work from there

Attached Thumbnails
Click image for larger version

Name:	6E 06-12 (1508 Tick)  3_30_2012.jpg
Views:	159
Size:	87.2 KB
ID:	72607  
Attached Files
Elite Membership required to download: MaxMinStoch.cs
Reply With Quote
Thanked by:
  #6 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: NinjatraderŽ
Broker: CQG, Kinetick
Trading: Gameplay KlownbineŽ Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

The coding of the Ninjatrader stochastic is pathetically inefficient, horrible, a joke. So it is not a good foundation for anything.

Calling the MIN and MAX functions on every tick is extremely resource intensive. unnecessary, and serves no useful purpose.

Since MIN and MAX are external classes, durable predefined instances of them should be created once and reused. Or, better still, the MIN and MAX routines should be placed inside the stochastic.

There is a thread on futures.io (formerly BMT) about Optimizing C# code. I wish somebody would read it. One of the posts on that thread is a superfast version of the DOUBLE stochastic. It illustrates the techniques that should be used in THIS indicator.

Maybe I will post an alternate version of this indicator to show how much better it can be made to work.

This type of coding is the cause of the vast majority of Ninjatrader performance problems. Throwing more cores at it, or switching to inferior platforms in disgust, are not the best solutions.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

Sorry, the NinjaTrader equivalent of Lowest is MIN. Told you I was rusty!

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21


Big Mike View Post
Sorry, the NinjaTrader equivalent of Lowest is MIN. Told you I was rusty!

Mike

ha...np mike

Started this thread Reply With Quote




Last Updated on May 6, 2012


© 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