Search | User Listing Vidsite | Calendars | Quotes
Home Page ->  OLang, OScript & OPilot -> Writing OLang Systems -> View ThreadLogon (or Register, or Join TradeTight)

You are logged in as a limited-access Guest.To join TradeTight, first read the info in the Organization & Content room, then click the link above. 

Luke 12:33 (NKJV) ... Sell what you have and give alms; provide yourselves money bags which do not grow old, a treasure in the heavens that does not fail, where no thief approaches nor moth destroys.


System signal not firing
Jump to page : 1
Now viewing page 1 [50 msgs/pg]
Jump to room :
BruceWilliamson
Posted 11/20/2021 11:15 PM (#9894)
Subject: System signal not firing



Spectator

Posts: 5
0
Location:
Australia: , Rhodes, NSW
Hi Folks

I posted this on the OT Pro Forum but haven't had a response yet so thought I'd try my luck on TT

I'm struggling to get the following system to fire any signals and hope that you may be able to help me spot the error. It's pretty basic pardon the pun but I am no VB expert. Attached is a screenshot of what I'm trying to capture with a fat X for the missing signal on the vote line. Below is the code for the #System and at the end, the debug values for the two days involved.

Any help much appreciated

Any questions, give me a shout

Cheers
Bruce

#PARAM "Long_Period", 10
#PARAM "Long_Lookback", 3
#PARAM "Short_Period", 20
#PARAM "Short_Lookback", 2

DIM myLB AS INTEGER
DIM myBAR AS INTEGER

myLB = MAX(Long_Lookback,Short_Lookback)

' This loop looks for reversal entry based on LLV/HHV
' With confirmation and positive close
FOR myBAR=1 TO myLB
  IF myBAR <= Long_Lookback _
  AND L[myBAR] = LLV(Long_Period) _
  AND C > H[myBAR] _
  AND C > O THEN
    Signal = LongSignal
    EXIT FOR
  ELSEIF myBAR <= Short_Lookback _
  AND H[myBAR] = HHV(Short_Period) _
  AND C < L[myBAR] _
  AND C < O THEN
    Signal = ShortSignal
    EXIT FOR
  END IF
NEXT myBAR


DebugMsg(LLV(10))
DebugMsg(L[1])
DebugMsg(O)
DebugMsg(H)
DebugMsg(L)
DebugMsg(C)
DebugMsg(Signal)


Day[1]
101.52
101.91
102.27
102.45
101.52
102.28
0


Day[0]
101.52
101.52
102.55
104.15
102.55
103.94
0



(OT22 Signal #0.PNG)




Edited by BruceWilliamson 11/20/2021 11:32 PM

Attachments
Attachments OT22 Signal #0.PNG (135KB - 2 downloads)
Top of the page Bottom of the page
JimDean
Posted 11/21/2021 7:54 AM (#9895 - in reply to #9894)
Subject: System signal not firing



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
Hi Bruce

You may have overthought this when coding it. No need for a for/next loop. OLang has an implicit “outer” loop that moves forward from bar 0 to the HRE, working on one bar then the next and so on. Your code is relative to the “current” bar in that loop.

So, all you need is to check for the condition you want and fire a signal, as the implicit loop moves forward. I’m using the conditions in your snapshot.

#system

If bar > 10 then

If L[1]= LLV(10) and C > O and C > H[1] then
Signal = LongSignal

Elseif H[1]= HHV(10) and C < O and C < L[1] then
Signal = ShortSignal

End if

End if

… you can add params if you want for the 10 and 1 values. But no need for for/next or intermediate dim’d variables.

Top of the page Bottom of the page
JimDean
Posted 11/21/2021 8:11 AM (#9896 - in reply to #9895)
Subject: System signal not firing



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
Here’s another thing to consider …

You might also want to specify that the slope of the price prior to the recent turn was opposite the trade direction.

Also, maybe make sure that the most recent close isn’t too high - that it’s not hitting a resistance level.

#system

If bar > 10 then

If L[1]= LLV(10) and C > O and C > H[1] _
and LnReg_Slope(5)[1] < 0 and C < HHV(C,10)[1] then
Signal = LongSignal

Elseif H[1]= HHV(10) and C < O and C < L[1] _
and LnReg_Slope(5)[1] > 0 and C > LLV(C,10)[1] then
Signal = ShortSignal

End if

End if
Top of the page Bottom of the page
BruceWilliamson
Posted 11/21/2021 9:11 PM (#9897 - in reply to #9896)
Subject: System signal not firing



Spectator

Posts: 5
0
Location:
Australia: , Rhodes, NSW
Hi Jim

Thanks a million for your response, much appreciated

The reason I have the loop is that I also want to check for LLV/HHV for the previous "n" periods i.e. for the scenario where it isn't a "V" bounce and takes a few days to develop, see attached for an example. Is there a better (more efficient) technique for accomplishing this look back processing?

The reason I'm using parameters is that once I get it working I want to optimise the LLV/HHV & look back periods independently for longs and shorts as I firmly believe they behave quite differently

Thanks for the tip on the linear regression, I was definitely going to incorporate a filter to prevent trading against the trend … whether that be short, medium or long term will come out in the wash during back testing and PortSim

Cheers
Bruce

(OT22 Signal #1.PNG)



Attachments
Attachments OT22 Signal #1.PNG (34KB - 2 downloads)
Top of the page Bottom of the page
JimDean
Posted 11/21/2021 10:19 PM (#9898 - in reply to #9897)
Subject: System signal not firing



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
I admit that I don't really follow what you are trying to do ... the code without the For/Next will find ALL qualified signals from the beginning to the HRE, without having to doubly-loop through the bars.

Have you tried running the code to see how it performs?

I've looked over your original code with the for/next and although I can't see a need for it, there are a few seemingly illogical aspects.

1. Your uses of C and O inside the loop logically should have some kind of [myBar] pointer.
2. The L & H values being checked should likely use [myBar+1] pointers.

I hope this helps.
Top of the page Bottom of the page
BruceWilliamson
Posted 11/21/2021 10:58 PM (#9899 - in reply to #9898)
Subject: System signal not firing



Spectator

Posts: 5
0
Location:
Australia: , Rhodes, NSW
Hi Jim

I apologise, I'm not sure what HRE stands for and a quick search didn't find anything explanatory ??

I'm trying to capture the scenario where the LLV does NOT immediately precede the entry bar so in the screenshot above, hopefully stepping thru the chart chronologically and my dodgy pseudocode will convey my thoughts:

27/4 LLV Occurs ' 1st condition met

28/4 C (NOT) > H[1] AND C (NOT) > O ' i.e. fails long signal test in both cases
IF L[1] = LLV(10) AND C > H[1] AND C > O THEN
Signal = LongSignal ' No


29/4 C > H[2] AND C > O ' i.e. passes long signal test in both cases
IF L[2] = LLV(10) AND C > H[2] AND C > O THEN
Signal = LongSignal ' Yes


N.B. On 29/4 the [] (square brackets) values are 2 not 1 hence why I thought the FOR loop was appropriate

In SQL or procedural code I would use recursion for the look back with a limit on how far I look back i.e. max 5 days for longs and 3 days for shorts

I hope this makes sense Jim and doesn't muddy the waters further ??

Cheers
Bruce
Top of the page Bottom of the page
Jump to page : 1
Now viewing page 1 [50 msgs/pg]
( E-mail a Link | Printer Version | Search Room )

Owner of site: Jim Dean -- Forum content is confidential, and may not be distributed without written permission.