Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Label function Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
machado
Posted : Sunday, May 22, 2011 7:08:40 PM
Registered User
Joined: 3/13/2005
Posts: 107
Hi can someone please tell me what is wrong with this piece of code. As writtin  the code will not plot but if i remove the Elseif part it will plot. Am I missing a statement or something


Thanks

If Price.DateValue.Day = 4 Then
    LABEL = "TEST1"
ElseIf    Price.DateValue.Day = 20 Then
    LABEL = "TEST2"

    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last

Else    
    OpenValue = Single.NaN
    HighValue = Single.NaN
    LowValue = Single.NaN
    Plot = Single.NaN
End If







machado
Posted : Wednesday, May 25, 2011 12:08:22 AM
Registered User
Joined: 3/13/2005
Posts: 107
Bruce can you please help me out on this one, I have been trying to figure this one out but to no avail.

The way I understand it with the IF statement is that it will execute the line if true then move to the ELSEIF then execute that line if true. Or is the IF statement and the ELSEIF more like an OR.

Hopefully that makes sense

anyway I would like to label the bar on the 4th of every month "Test1" and also label the bar on the 20th of evey month "test2"

Thanks
Bruce_L
Posted : Wednesday, May 25, 2011 7:38:53 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You aren't Plotting anything when Price.DateValue.Day = 4. Everything you want to happen must be contained after the If line and before the next Else If, Else or End If line.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
machado
Posted : Wednesday, May 25, 2011 8:52:57 AM
Registered User
Joined: 3/13/2005
Posts: 107
Thanks Bruce for your response,

I have tried writing it  several diferent ways for instance:

If Price.DateValue.Day = 4 Then
    LABEL = "TEST1" AndAlso _
        Price.DateValue.Day = 18
    LABEL = "TEST2"

    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last

Else    
OpenValue = Single.NaN
HighValue = Single.NaN
LowValue = Single.NaN
Plot = Single.NaN
End If

Also like this

If Price.DateValue.Day = 4 Then
    LABEL = "TEST1" AndAlso _
        Price.DateValue.Day = 18 Then
    LABEL = "TEST2"

    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last

Else   
OpenValue = Single.NaN
HighValue = Single.NaN
LowValue = Single.NaN
Plot = Single.NaN
End If


The one that does plot is as follows:

If Price.DateValue.Day = 4 Then
    LABEL = "TEST1"

    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last

Else   
    OpenValue = Single.NaN
    HighValue = Single.NaN
    LowValue = Single.NaN
    Plot = Single.NaN
End If


I cant figure out how to label both datevalues


Thanks so much for your help Bruce
Bruce_L
Posted : Wednesday, May 25, 2011 8:57:33 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If Price.DateValue.Day = 4 Then
    LABEL = "TEST1"
    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last
Else If Price.DateValue.Day = 18
    LABEL = "TEST2"
    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last
Else   
    OpenValue = Single.NaN
    HighValue = Single.NaN
    LowValue = Single.NaN
    Plot = Single.NaN
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
machado
Posted : Wednesday, May 25, 2011 9:18:03 AM
Registered User
Joined: 3/13/2005
Posts: 107
Ahhhh I get it now I thought that the

OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last

section didnt have to be replicated under the Else if line
It makes perfect sense

Do you recomend any books so I can get a better handle on real code

Bruce Thanks your the man
Bruce_L
Posted : Wednesday, May 25, 2011 9:22:46 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The RealCode Programmers Reference and RealCode API documents, RealCode for Real People: Indicators and Writing Conditions in RealCode videos, and  Intro to RealCode and Intro to RealCode Episode II webinars are designed to cover the portions of RealCode that are specific to StockFinder.

Beyond that, RealCode is based on Visual Basic (VB.NET). While I cannot make any specific recommendations as to which book or website might be best for you to learn Visual Basic (VB.NET) itself, there are a lot of books and websites on the subject. You might even be able to find a class at your local college or university on Visual Basic (VB.NET) if books and websites don't fit your particular learning style.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
machado
Posted : Wednesday, May 25, 2011 9:32:22 AM
Registered User
Joined: 3/13/2005
Posts: 107
Bruce thanks so much for your help it is much appreciated.
jas0501
Posted : Wednesday, May 25, 2011 5:16:16 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
QUOTE (Bruce_L)
If Price.DateValue.Day = 4 Then
    LABEL = "TEST1"
    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last
Else If Price.DateValue.Day = 18
    LABEL = "TEST2"
    OpenValue = Price.Open
    HighValue = Price.High
    LowValue = Price.Low
    Plot = Price.Last
Else   
    OpenValue = Single.NaN
    HighValue = Single.NaN
    LowValue = Single.NaN
    Plot = Single.NaN
End If

could be

If Price.DateValue.Day = 4  or Price.DateValue.Day = 18 Then
     LABEL = IIF(DateValue.Day = 4,"TEST1","TEST2")
     OpenValue = Price.Open
     HighValue = Price.High
     LowValue = Price.Low
     Plot = Price.Last
Else
     OpenValue = Single.NaN
     HighValue = Single.NaN
     LowValue = Single.NaN
     Plot = Single.NaN
End If
jas0501
Posted : Wednesday, May 25, 2011 5:23:42 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
QUOTE (machado)
...
...
Do you recomend any books so I can get a better handle on real code
...
...


Looking at the candlestick indicators as they are realcode or downloaded shared charts and layouts and reviewing that code will provide code with a meaningful context, which can make understanding easier.

Also messing with the code and adding log.info displays will help appreciate how the code works helps. Doing this with a watchlist of 1 and 500 bars will keep the experiments bounded and you won't get stuck on the fly-paper of 5000 bars and 1000 symbols of log.info displays.


machado
Posted : Wednesday, May 25, 2011 9:19:49 PM
Registered User
Joined: 3/13/2005
Posts: 107
Thanks Jas for the alternitive code its very helpful.

Yes I have been looking at the caned candelstick indicators they have be giving me futher insights on writing this stuff , it takes a litle bit of trial and error to get .net right (for me anyway). Its all about the syntax .

Thanks guys for all your help
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.