Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

showmessage Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
pthegreat
Posted : Sunday, July 14, 2013 5:44:53 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

Hi bruce,

please look at the code I've posted here:

http://forums.worden.com/default.aspx?g=posts&t=58697

I'm trying to add a popup message when price has crossed up through the "entry" level.

I have added the code, as per this capture:

http://screencast.com/t/uelJQw6F7a

but it's not working, it'll endlessly popup messages.

This is what I want to achieve : 

example V on 60min (have to change "entrypercent to 25%, in order to get the "entry" cross)

http://screencast.com/t/71jt2OPL

Do you know of a way to just show a single message when the cross occurs?

thanks.

 

Bruce_L
Posted : Monday, July 15, 2013 11:39:16 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Add something like the following to the beginning of your RealCode:

Static Sym As String

Then change:

If price.Bar.lastvalue(k - 1) < entry Then

To:

If Price.Bar.Value(k - 1) < entry AndAlso Sym <> CurrentSymbol Then

With the following line in addition to the showmessage inside the If construct:

Sym = CurrentSymbol

If you switch away from a symbol with a message and switch back without any other messages showing, the symbol will not show the message again. But if there is a message from another symbol in between, then the symbol will show the message again.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pthegreat
Posted : Tuesday, July 16, 2013 10:46:50 AM

Registered User
Joined: 6/15/2008
Posts: 1,356

fantastic. thanks !

pthegreat
Posted : Tuesday, July 16, 2013 12:11:40 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

Also trying to get an audible alert:

 

If Price.Bar.lastValue(k) > entry AndAlso k <= Range(1) Then
   If k = Range(1) Then
      If price.Bar.lastvalue(k - 1) < entry AndAlso sym <> CurrentSymbol Then
         sym = CurrentSymbol
         lokistatic.playsound("c:\lightbulb.wav")
         showmessage("cross entry on " & Me.currentsymbol)
      End If
   End If
 
copied the wav file to C:\   , made sure it plays.
but doesn't play when a message pops up.
 
Bruce_L
Posted : Tuesday, July 16, 2013 12:50:05 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I do not know. When I do essentially the same thing (but with notify.wav instead of lightbulb.wav), it works just fine and plays the sound whenever there is a popup.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pthegreat
Posted : Tuesday, July 16, 2013 1:25:09 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

ok, got it.

some of my wav files work, and some don't.

no problem, just used another file.

thanks again.

pthegreat
Posted : Wednesday, July 17, 2013 12:10:28 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

Since I use multiple charts with different timeframes at the same time I want when the message pops up, to show the timeframe as well.

I wrote the following as a private subroutine:

Private Sub TFrame (tframe As String)
   If me.BarInterval.Days > 0 then
      Select Case Me.TimeFrame.TotalDays ' daily timeframes
         Case  1 
            tframe = "daily"
         Case 2
            tframe = "2days"
      end Select
   else 
      Select Case Me.BarInterval.TotalMinutes ' minute timeframes
         Case 1
            tframe = "1min"
         Case 2 
            tframe = "2min"
         Case 3
            tframe = "3min"
         Case 5 
            tframe = "5min"
         Case 8
            tframe = "8min"
         Case 10 
            tframe = "10min"
         Case 15
            tframe = "15min"
         Case 30 
            tframe = "30min"
         Case 60
            tframe = "60min"
         Case 120 
            tframe = "120min"
      End Select
   end if
End Sub

then I'm trying to incorporate the tframe string into the showmessage command:

showmessage("entry AB=CD up, on " & WhatTimeFrame.tframe & Me.currentsymbol)

and :

showmessage("entry AB=CD up, on " & WhatTimeFrame & Me.currentsymbol)

both give me the error :

argument not specified for parameter "tframe" of 'Private Sub WhatTimeFrame(tframe as astring)'

 

pthegreat
Posted : Wednesday, July 17, 2013 12:11:55 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

oops sorry:

Private Sub TFrame (tframe As String)

is

Private Sub WhatTimeFrame (tframe As String)

 

Bruce_L
Posted : Wednesday, July 17, 2013 12:58:07 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I'm not a programmer and couldn't say what might be wrong with your technique. That said, if we change this from a Sub to a Function:

	Private Function WhatTimeFrame() As String
		Dim tframe As String
		If me.BarInterval.Days > 0 then
			Select Case Me.TimeFrame.TotalDays ' daily timeframes
				Case  1 
					tframe = "daily"
				Case 2
					tframe = "2days"
			end Select
		else 
			Select Case Me.BarInterval.TotalMinutes ' minute timeframes
				Case 1
					tframe = "1min"
				Case 2 
					tframe = "2min"
				Case 3
					tframe = "3min"
				Case 5 
					tframe = "5min"
				Case 8
					tframe = "8min"
				Case 10 
					tframe = "10min"
				Case 15
					tframe = "15min"
				Case 30 
					tframe = "30min"
				Case 60
					tframe = "60min"
				Case 120 
					tframe = "120min"
			End Select
		End If
		Return tframe
	End Function

Then we can use:

showmessage("entry AB=CD up, on " & WhatTimeFrame() & Me.currentsymbol)


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pthegreat
Posted : Wednesday, July 17, 2013 1:39:01 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

The error cleared, however it does NOT show in the pop up message

besides 

showmessage("entry AB=CD up, on " & WhatTimeFrame() & Me.currentsymbol)

 

I tried :

If k = Range(1) Then
   If price.Bar.lastvalue(k - 1) < entry AndAlso sym <> CurrentSymbol Then
      Dim msgtxt As String
      msgtxt = "entry AB=CD up, on " & WhatTimeFrame()
      sym = CurrentSymbol
      lokistatic.playsound("c:\notify.wav")
      showmessage(msgtxt & Me.currentsymbol)
   End If

 

End If
 
In both cases the popup message shows:
 
entry AB=CD up, on V    
 
so it does not show the timeframe
 
pthegreat
Posted : Wednesday, July 17, 2013 1:58:23 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

ok, got it!

forgot the "return tframe" statement in the function.

thanks.  

 

Bruce_L
Posted : Wednesday, July 17, 2013 1:59:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I'm still not a programmer and I still can't troubleshoot your code, but you could try replacing your function with something shorter:

	Private Function WhatTimeFrame() As String
		Dim tframe As String
		If me.BarInterval.Days > 0 then
			tframe = Me.BarInterval.Days & " Days "
		else
			tframe = Me.BarInterval.TotalMinutes & " Minutes"
		End If
		Return tframe
	End Function


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Bruce_L
Posted : Wednesday, July 17, 2013 2:00:25 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

OK, I'm happy to read you were able to figure it out.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pthegreat
Posted : Wednesday, July 17, 2013 2:12:40 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

ah, much better.  

need to study a bit more on functions, subs, etc..   organize my spagetti code

thx Bruce!

 

pthegreat
Posted : Tuesday, August 27, 2013 11:21:00 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

Hi bruce, I want to explore if there is a way to make this work a little better.

I have written this into a condition, that sorts a watchlist.

the message keeps triggering several times during the bar where price surpasses the "entry".

I'd like to find a way that it'll show the message just once for the bar, where the condition passes.

my thinking on how to tackle this so far:

register the exact time where price surpasses the "entry".

write the ticker and time when the condition passed into a "list" , or an array perhaps.

for argument sake, for example AAPL passed at 15:36:00 on a 5min chart, and the condition runs every 15 seconds.

so write AAPL with the time into an array. (or maybe we could/have to use the hashtable thingy for this)

next time the condition runs, at 15:36:15 , and AAPL still passed the condition then check the array, determine that AAPL's last entry was still on the same current 5min bar, and therefore DO NOT do the "showmessage - lokistatic" routine.

So the first step I want to find out is if there is a way to register the time when the price surpasses the "entry", and for now as an exercise add the time to the showmessage.

Do you know how we can capture the time at a certain event?

Hope I'm making sense, and as always open; to any of your thoughts.

thx,

P.

 

Bruce_L
Posted : Wednesday, August 28, 2013 10:55:43 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

A label for the current time of day could be written as:

Label = DateTime.Now.TimeOfDay.ToString

But you could probably just store DateTime.Now instead of the text you would use in the label. This would allow you to compare the stored date to Price.DateValue(1). If the stored date is less than or equal to Price.DateValue(1), then it was caclulated during the previous bar and not the current bar.

I am guessing you would have two static lists. One would just be a list of symbols and the other would be a list with the DateTime when the symbol was added to the other list. That said, I am not a programmer and do not have any suggestions as to the exact details.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pthegreat
Posted : Wednesday, August 28, 2013 1:30:08 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

me neither; not a programmer. :-) but really appreciate your ideas and suggestions, it has helped me a lot.

So I will spend some time on this. If I get anything workable I'll post it.

thx,

P.

pthegreat
Posted : Wednesday, October 9, 2013 8:01:23 PM

Registered User
Joined: 6/15/2008
Posts: 1,356

QUOTE (pthegreat)

So I will spend some time on this. If I get anything workable I'll post it.

thx,

P.

see:

http://forums.worden.com/default.aspx?g=posts&t=52507

If you have any ideas to improve on the code plz let me know.

thx

 

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.