I'm on the road now so I'll respond more clearly when I'm back.
Getting the value of most recent swing hi/lo has confused me as close doesn't have a value, and there are times when no hi|lo is drawn or has a null(zero?) value for some time. I'm sure its a "duh" thing that I am missing. In RJay's example its the "swing high" and "swing low" that has me stumped.
Totally OT to my own thread () I'm trying GoToMyPC for the first time and am chuffed that I can access my three-screen trading rig back home while sitting in a hotel in a different country with my laptop.
Piresh that is very close to what I am trying to do. Before I saw your code I wrote this:
Which doesn't work. You will see I'm trying an OR condition as well. The logic is;
The swing range needs to be wide enough OR the current SwingLow is 0 for shorts
The swing range needs to be wide enough OR the current SwingHigh is 0 for longs
I'll play some more and post it back!
EDIT TO ADD: For newcomers to Ninja Script [I include myslef in that comment!] you will see I'm making to simple mistakes in the code that I'm fixing as I go along. Look at the difference in the draw arrow code from this to the next.
Last edited by MXASJ; October 2nd, 2009 at 03:11 AM.
Always use Print statements to see what the data looks like if you are having trouble. Open the output window.
You might want to only know when a new Swing high or low has been formed, which you need to write some code to detect.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
What appears to be happening is it only trades "breakouts" from the swing zone (fair enough, based on the entry trigger), but the 12 tick filter stays in place even if no new swing line is drawn on the chart by the indicator. What that means is if we are in a 14 tick swing range and it breaks out, a trade is put on. If we are in a 12 tick or less range and the price breaks out, it will NOT trade until a new swing range greater than 12 is drawn. So some of those lovely swing breakouts that keep climbing up or down are NOT traded if the previous swing range was <12... until they top or bottom out and a new swing range >12 is drawn by the indicator. Hmmm ...
Last edited by MXASJ; October 2nd, 2009 at 04:21 AM.