OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Professional Forum
OmniLanguage Discussion
Help on Olang - System
Last Activity 7/6/2025 3:47 AM
10 replies, 5266 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
Duxx

Elite
500100100100252525
Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : Help on Olang - System
Posted : 8/25/2010 10:31 PM
Post #16874

Hi

Im trying to set up a system and an indicator.

I want

To capture a lower low from prior bar I have the following:

L[1] < L[2] and L > L[1]

Then, I want to fire a long if the Close is above the high of the lowest low captured above as follows:

C > H[1]

But the issue is that life is not perfect and the current bar close may not be higher than the high of the lowest low, so I have the following:

# Param "NBars",5,1,10

Dim xCount, yCount, zCount As Single

if L[1] < L[2] and L > L[1] then

xCount = 1 'records the fact that the conditons above have been met
end if

if xCount = 1 and C > O and C > H[1] then 'sets next test condition
yCount = 1 'records the conditions here met
else yCount = 0
end if

if xCount = 1 then
zCount = zCount[1] + 1 'causes a count up of the number of bars passed since the first condition was met
'else If xCount = 0 then
'zCount = 0
end if

if yCount = 1 then
signal = longsignal
End if

If zCount = NBars or yCount = 1 then
xCount = 0
yCount = 0
zCount = 0
end if


But the above does not work precisely as described and Im not sure how to apply the same process for a short (which is the inverse)

Any ideas are welcome

Thanks

[Edited by Duxx on 8/25/2010 10:41 PM]

^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/25/2010 10:39 PM
Post #16875 - In reply to #16874

L[1]L[1] does not mean anything at all.

I am surprised that it compiled without error.

"capture a lower low from a prior bar" ... not sure what you mean ... do you mean you want a condition where the prior bar's low is lower than the current bar ... or the opposite?

The first of those would be:
L[1] < L
The opposite would be:
L < L[1]

^ Top
Duxx

Elite
500100100100252525
Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/25/2010 10:41 PM
Post #16876 - In reply to #16875

Jim, Im not sure what is going on on the forum, but it did not post correctly, but when I do edit - it shows correctly.
L[1]L[1]


This is what it should read - for some reason the forum does not take my brackets
L(1) (the 1 is on brakets) < L(2) (the 2 is on brackets and L>L(1) (The one is on brackets)



[Edited by Duxx on 8/25/2010 10:46 PM]

^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/25/2010 10:47 PM
Post #16878 - In reply to #16876

Try a snapshot of the OLang editor
^ Top
Duxx

Elite
500100100100252525
Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/25/2010 10:53 PM
Post #16879 - In reply to #16878

Here it is



[Edited by Duxx on 8/25/2010 10:55 PM]

Attached file : 8-25-2010 8-52-42 PM.png (25KB - 548 downloads)

^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/26/2010 11:21 AM
Post #16890 - In reply to #16879

Duxx,

What you can do is define your "pattern" formation in a single boolean statement (occuring if = true) and use a single counter, you dont need 3. If true you reset the counter, Else increase the counter by 1. This will keep track of how many bars have passed since the most recent pattern formed.

After your pattern has formed you would then check your trigger condition if the counter is less than or equal to your parameter threshold. I.E.


#System
#PARAM "NBars", 5, 1, 10

Dim nBarsSincePattern as Integer

If L[1] < L[2] And L > L[1] Then
nBarsSincePattern = 0
Else
nBarsSincePattern += 1
End If

If nBarsSincePattern <= NBars Then
If C > O and C > H[nBarsSincePattern + 1] Then Signal = LongSignal
End If

p.s. - I edited your top post to correct the missing comparison signs. The issue is with the spacing between the < and > signs. You must have a whitespace to both the right and left of it or it is treated as HTML.
^ Top
Duxx

Elite
500100100100252525
Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/26/2010 11:55 AM
Post #16891 - In reply to #16890

Matt

Thank you for simplifying the code, much clearer.

Two questions:

1) Right now the signal is trigger when

C > O and C > H

But I would like to trigger the above signal, when the close of current bar is higher than the lowest low.

This means the following, the pattern formation is:

L[1] < L[2] And L > L[1]

That means that L[1] is the lowest low at that time, so I want to trigger the signal when the following bars close above that L[1] which should be the lowest low.

Dont know how to do this......

2) Can I copy the same code on the bottom change the pattern and signal for short and would this work including short signals?


Thank you so much
^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/26/2010 12:26 PM
Post #16892 - In reply to #16891

In your first post you state

Originally written by Duxx on 8/25/2010 10:31 PM
Then, I want to fire a long if the Close is above the high of the lowest low captured...


So in the code I provided you can see that I always check the current close against the High of the bar that made the lowest low bar using the code...

C > H[nBarsSincePattern + 1]


However now you mention that you want the C to be greater than the Low value of the lowest low bar.

Originally written by Duxx on 8/26/2010 11:55 AM
But I would like to trigger the above signal, when the close of current bar is higher than the lowest low.


In which case you can just change

C > H[nBarsSincePattern + 1]

to...

C > L[nBarsSincePattern + 1]

However using the low does not make a lot of sense since if your pattern has formed the close of the last bar in the pattern will always be greater than the L of the prior bar (your pattern is formed by a lower low). So a signal will fire on every green bar (C > O) after your pattern.
^ Top
Duxx

Elite
500100100100252525
Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/26/2010 12:31 PM
Post #16893 - In reply to #16892

Im miss that part - thank you Matt!
^ Top
Duxx

Elite
500100100100252525
Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/28/2010 12:15 PM
Post #16913 - In reply to #16890

Matt or someone else

Im trying to figure out the logic on the counter you kindly provided, trying to learn how this works.

First the system try to find the pattern, and when it finds the pattern, the the counter is set to zero with nBarsSincePattern = 0

If the pattern is not found, the pattern = 1 with nBarsSincePattern +=1

But Matt mentioned that the above formula nBarsSincePattern +=1 is more like an increase by 1, so can I assume that by setting up nBarsSincePattern as integer (does this means any integer or just the number 1 integer?) then the + sign on the formula would increase the integer by 1?

Im also unclear why this function H[nBarsSincePattern + 1] requires the + 1

Your guidance is appreciated
^ Top
Matthew Greenslet

Idol
2000252525
Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : RE: Help on Olang - System
Posted : 8/30/2010 11:53 AM
Post #16930 - In reply to #16913

An Integer is any whole number I.E. -2, -1, 0, 1, 2, ect.

the += syntax is a standard coding meaning add some value to the orginial

nVar += 1 will return the same result as nVar = nVar + 1.

The reason I use a lookback of nBarsSincePattern + 1 is because your pattern definition requires 3 bars to make a pattern where the middle bar forms the lowest low. We reset the counter to 0 on the right most bar of your pattern. Since you wanted to reference some price point of this middle bar we need to lookback 1 bar + the number of bars since the last pattern reach the middle bar you wanted to use.
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.