NexusFi: Find Your Edge


Home Menu

 





Need help with PKPriceAlert2 indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Todd with 9 posts (2 thanks)
    2. looks_two max-td with 9 posts (3 thanks)
    3. looks_3 ZTR with 2 posts (1 thanks)
    4. looks_4 MartinS with 1 posts (0 thanks)
    1. trending_up 6,019 views
    2. thumb_up 6 thanks given
    3. group 2 followers
    1. forum 21 posts
    2. attach_file 5 attachments




 
Search this Thread

Need help with PKPriceAlert2 indicator

  #11 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

hey Todd - we come near the target !

great to hear you mastered the errors now - it was all because of wrong or missing brackets - well - that happens easiely.

now you miss still the sound alert - here is the solution -maybe i wasnt clear enaugh here :

down in the code in lines from 90 to 120

alertOBStoch in the code must be WITHOUT quotes ( " ... " ) !

like this :

 
Code
                            
"  Price=" PriceAlert ,  alertOBStoch 60Color.Blue,Color.White); 



and then you insert you wished wav-file in the parameters.
then that work !


..

max-td
Attached Thumbnails
Click image for larger version

Name:	sound-2010-02-18_182239.png
Views:	186
Size:	1.6 KB
ID:	8328  
Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
 
Todd's Avatar
 Todd 
Alpharetta, GA
 
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 234 since Jun 2009
Thanks Given: 28
Thanks Received: 40

Hey Max,

That worked!!

Almost to the finish line...

Two final things...

#1
Can you tell me what lines of code I need to change to get the fields on indicator screen to not say "AlertOBStoch" and "AlertOSStoch". I'm not talking about the input field where I enter the wav file name, I'm talking about the other field in the left column.

I tried replacing AlertOBStoch and AlertOSStoch in the variables section, the code section and the properties section. I got the error shown in the attached link. I'm sure I'm missing something very simple, just don't know what it is...
https://screencast.com/t/YzgwNGY0Yzg
https://screencast.com/t/NzUxYWQ3NzIt
https://screencast.com/t/NDM2NGIyNmY

Edit added - 5:45pm 2-18-10
Even though it says the error is in lines 138 and 146, I decided to take screencasts of the other 2 sections of code also. I thought I followed what you had done in your Stoch-D indicator but I've obviously got something slightly (or majorly) wrong.




#2
For some reason, in order to have this indicator work for cases where price is piercing up thru the horizontal line AND cases where price is piercing down thru the horizontal line, you've got to select this indicator twice from the indicator list - one for uptrend and one for downtrend. That seems weird considering that the code seems to have places for "price breaking up thru line" and "price breaking down thru line".

Can you read the code well enough to understand why you would need two occurences of the indicator? If you understand it and it must be that way, can you explain it? If you understand it and can change the code so it won't need two occurences of the indicator, can you do that or tell me how to do that?

I can live with the indicator like it is (especially after I get issue #1 above resolved), however, it seems stupid to need two occurences of the indicator - 1 for uptrend and 1 for downtrend. But what do I know...

Thanks again for the help.

Todd

Started this thread Reply With Quote
  #13 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


hi again,
to #1 - i think all you did is OK but the error is in lines 138 and 146 - right.

compare those lines again exactly with my example and have a look to what is written with a first big letter + what is written with a first small one - thats the key here i think.

all these micro-details - i also ran into these errors as i started to try my first codes 1,5 years ago or so -- i started with knowing nothing at all about coding - never learned this in school or elsewhere ... didnt know that there are such grazy traps - lol

max-td
Reply With Quote
  #14 (permalink)
 
Todd's Avatar
 Todd 
Alpharetta, GA
 
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 234 since Jun 2009
Thanks Given: 28
Thanks Received: 40

Hey Max,

You were right... the lower case and capital letters were the difference. I missed that. THANKS!

Do you have any thoughts on issue #2 that I raised in my last post?

Todd

Started this thread Reply With Quote
  #15 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

great to hear !

yes i have some thoughts -- i post later -- need lunch now

max-td
Reply With Quote
  #16 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

here you see whats the logic for alert to the upside :

 
Code
                            

                    
if ( (this.uptrend == true) &&
                         (
Close[0] > Close[1])   && 
                         (
Close[0] > PriceAlert) &&
                         (
Close[1] < PriceAlert)    ) 
Close[0] means the Close of very last candle
Close[1] means the Close of the candle before that.
PriceAlert means the value you horizontal line sits on

so the indie works with the closing-price of the bars.
if your candel peaks the Alert-line with its High but then closes below again - you dont get an alert!

thats the rules in the code here.
the next step is up to you again

BTW - did you try it with calconbarclose set to false ?

...

max-td
Attached Thumbnails
Click image for larger version

Name:	PK-Alert.png
Views:	193
Size:	4.6 KB
ID:	8404  
Reply With Quote
  #17 (permalink)
 
Todd's Avatar
 Todd 
Alpharetta, GA
 
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 234 since Jun 2009
Thanks Given: 28
Thanks Received: 40

Max,

Thanks..

2 Issues...
1. If I wanted to change the code to have it give an alert if the horizontal line price is touched instead of just a close beyond it, how would I do that?


2. Do you know if it's possible to change the code so I don't need to put 2 of these indicators in my chart instead of just 1? This isn't a big hassle, it's just more of the principle... it seems like bad code to need to put 2 of the same indicator on the chart to make it work.

To make it work for price piercing up thru the line or price piercing down thru the line, I'm guessing that you would need to add some "OR" statements. But I don't know if that is easy to do in NT.

I've posted the current code at the bottom of this code if that is helpful to anyone. It's a work in progress but here are the improvements so far...
1. It works on instruments with 2 digits after the decimal (like ES) and also works on charts with 4 digits like 6a, 6e, 6b, etc.

2. Audio Input File Fields have been added to the indicator input screen so you don't have to be stuck with one alert or change the alert in the code.

Todd

Attached Files
Elite Membership required to download: PKPriceAlert2.zip
Started this thread Reply With Quote
  #18 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


Todd View Post
1. If I wanted to change the code to have it give an alert if the horizontal line price is touched instead of just a close beyond it, how would I do that?

hmm Todd - i realy try to help you to understand what you do in the code.

if we now have the Close of the Bar as a trigger-value - and it doesnt trigger when it only peaks the line and closes below it again - what do you think may help here ? its no big coding-trick - its just an easy logical thing.

about combining up+down alerts - it may give a lot of signals+noise if price oscilates around the line - maybe thats why its seperated now - its made as a clear one-time-signal when trigger happens.

you can try it with commenting out the "up or down- condition-check" like this and test how it behaves :

 
Code
                            
//   (this.uptrend == false) &&


//  (this.uptrend == true) && 

..

max-td
Reply With Quote
  #19 (permalink)
 
Todd's Avatar
 Todd 
Alpharetta, GA
 
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 234 since Jun 2009
Thanks Given: 28
Thanks Received: 40

Max,

A minute ago I wrote a long reply but somehow when I hit submit, there was an error that erased it.

Anyway, I understand the "close of bar" logic. I just don't know the NT language so I don't know how to say "touch of price" with regard to the price bar. However, "close of bar" may be better because it may prevent from getting a bunch of alerts at one time as price moves back and forth across the line within 1 bar.

Regarding the uptrend/downtrend thing... I'll comment those lines out and see what happens. I'm guessing that the code will just stop working when I comment out those lines but we shall see.

Any idea why this indicator would only work in real time and not when I do market replay?

Todd

Started this thread Reply With Quote
  #20 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


OK - so here my thoughts :

in general every Bar has 4 clear defined "datas" : Open / Close / High / Low

a peak of this line without a Close above means, that the price WAS above the line one time.
If the price was above ths line, i have the HIGH of this Bar above the line !
so i use the High instead the Close - thats my logical "trick" here.

why its not working on marketreplay -- dont know.

try the commenting-out - it should work - try if its making sense for your need.

cu later

..

max-td
Reply With Quote




Last Updated on February 26, 2010


© 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