Another CrossBelow/Above question from newbie - NinjaTrader Programming | futures io social day trading
futures io futures trading


Another CrossBelow/Above question from newbie
Updated: Views / Replies:1,838 / 3
Created: by Al2010 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Another CrossBelow/Above question from newbie

  #1 (permalink)
Trading for Fun
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 50 since Oct 2010
Thanks: 36 given, 10 received

Another CrossBelow/Above question from newbie

Hello,
I wrote a simple program that draws arrows whenever the Stochastic crosses above 20 or below 80. But sometimes the Stoch. completes the cycles before crossing 20 or 80. Unfortunately I'm not smart enough to write smth more complicated and need help with this if possible please. I do not know if this is too much to ask. Please let me know if this is the issue.
The idea is simple - to get a single arrow per cycle. Currently the program draws the arrows whenever the Stoch crosses 20 then 30, 40 etc... But what I want is to check for all crosses, e.g. CrossAbv 20, 30, 40... and if either one is true then draw the arrow and disregard the rest of the crosses. Below is the simple test code I wrote, which works lk OR, e.g. drawing arrows if cross abv 20 or 30, or 40... It would work if the Stoch. completes the cycle before crossing below 20% line then reverses somewhere around 25% and keep rising. But again, it would draw the arrows at 30, 40... But I want only one arrow per cycle, e.g. if it reverses at 25 then check for crosses above 25 and if cross abv 30 = true draw arrow and disregard the rest of the checks.

private int crsAbvCheck = 0;
bool crsAbv20 = false;
bool crsAbv30 = false;
bool crsAbv40 = false;
bool crsAbv50 = false;

OnBarUpdate....

if (CrossAbove(Stochastics(periodD, periodK, smooth).K, 20, 1))
{
crsAbv20 = true; crsAbvCheck = 20;
}
else if (CrossAbove(Stochastics(periodD, periodK, smooth).K, 30, 1))
{
crsAbv30 = true; crsAbvCheck = 30;
}
else if (CrossAbove(Stochastics(periodD, periodK, smooth).K, 40, 1))
{
crsAbv40 = true; crsAbvCheck = 40;
}
else if (CrossAbove(Stochastics(periodD, periodK, smooth).K, 30, 1))
{
crsAbv50 = true; crsAbvCheck = 50;
}
else
{
crsAbv20 = false; crsAbv30 = false; crsAbv40 = false; crsAbv50 = false; crsAbvCheck = 0;
}

if (crsAbv20 || crsAbv30 || crsAbv40 || crsAbv50) { Print("Cross abv = " +crsAbvCheck+ "---Time:......"+Time[0]); }

I do not know how to write a code that would draw arrow for the first cross and would disregard the rest.
Another thing that comes to mind but I do not have enough skills to implement this is how to check the MACD cross if Stoch. cross returns false, which sounds simple....
Thank you very much.

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Calcutta, India
 
Futures Experience: Intermediate
Platform: ArthaChitra
 
Posts: 278 since Jun 2009
Thanks: 161 given, 259 received


i really didnt get what exactly you want, but your logic is wrong.

say the current stochastic value is 55.

now your code first checks whether the same is greater than 20. and ya sure it is, thus it skips the rest of the elseif code.

you got to code it this way

if (stochastic > 20 && stochastic <30)
{
//do something
}
else if (stochastic > 30 && stochastic < 40)
{
//do something
}

and likewise. hope you got the point. sorry for the crude code.

Reply With Quote
The following user says Thank You to bukkan for this post:
 
  #4 (permalink)
Trading for Fun
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 50 since Oct 2010
Thanks: 36 given, 10 received


bukkan View Post
i really didnt get what exactly you want, but your logic is wrong.

say the current stochastic value is 55.

now your code first checks whether the same is greater than 20. and ya sure it is, thus it skips the rest of the elseif code.

you got to code it this way

if (stochastic > 20 && stochastic <30)
{
//do something
}
else if (stochastic > 30 && stochastic < 40)
{
//do something
}

and likewise. hope you got the point. sorry for the crude code.


Thank you very much for you reply.
I think this will still work as OR. If the Stoch is below 20 and rising then if the Stoch > 20 && < 30 then cross abv 20 = true-draw arrow up. If Stoch. keeps rising and > 30 && < 40 then cross abv 30=true... Which will draw arrows first @20 then @30...@40... I maybe wrong but I don't think the else if will be skipped as you suggested. Or in case the Stoch is above 30 and rising the arrows will be drawn @ 30 and @40... But how to stop drawing arrows at the first cross, whichever cross this would be-20-30 or 40...? Then the next cross should be checked only when the prev. cycle is complete. This is the problem I cannot figure out.

Here is the example: the first cross was @20-draw arrow up at 20. Then the Stoch keeps rising abv 50 or higher. In this case only one arrow @20 should be drawn and crosses abv 30-40 should be disregarded.

Another example: In my code i have all three checks-if cross abv 20-30 or 40 true then do smth. The stoch is below 20 and rising - cross abv 20=true-then draw arrow up. Then after cross abv 20 it continues rising above 50-55. Then it reverses and falling and reached 27. Then it reverses back up @27 (creating higher low - the first low was below 20) and keeps rising. In this case the previous cross abv 20 and the cross above 30 are true and both arrows should be drawn at 20 and 30. Bcs to me the Stoch. completed the cycle going above 50 then it reverses back down and started the new cycle up @ 27. The cross above 40 should be disregarded - no arrow @40.



Thank you very much.


Last edited by Al2010; December 4th, 2010 at 09:10 PM.
Reply With Quote

Reply



futures io > > > > > Another CrossBelow/Above question from newbie

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie Question about Autotrading (NT7) NJAMC The Elite Circle 3 April 6th, 2011 03:52 PM
newbie stupid question!!!! bugsbunny NinjaTrader Programming 29 February 10th, 2011 10:19 AM
Need help with Btween and CrossBelow/Above - C# newbie Al2010 NinjaTrader Programming 2 November 22nd, 2010 11:27 PM
Newbie Question about Forex jra_020883 Beginners and Introductions 5 March 8th, 2010 07:05 PM
ZN Newbie question NMTrader Traders Hideout 8 July 19th, 2009 10:59 PM


All times are GMT -4. The time now is 03:34 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-16 in 0.11 seconds with 19 queries on phoenix via your IP 54.196.201.241