|
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Mon Apr 05, 2010 1:50 pm
Need some help with a trigger... |
I have two triggers setup. Trigger 1 fires after example text 1 has been received using trigger states that fire when each line is received within 1 line of the one before. Trigger 2 fires after example text 2 has been received in the same way. The problem is that Trigger 1 fires on the 3rd line of example text 2 (as you might expect) but I do not know how to work things so that Trigger 1 does not fire for example text 2.
Example text 1:
Code: |
>c price alloys
+++ The exchange display shows the prices for Alloys +++
+++ Exchange has 900 tons for sale +++
+++ Offer price is 348ig/ton for first 75 tons +++ |
Example text 2:
Code: |
>c price univators
+++ The exchange display shows the prices for Univators +++
+++ Exchange has 900 tons for sale +++
+++ Offer price is 448ig/ton for first 75 tons +++
+++ Exchange will buy 75 tons at 421ig/ton +++ |
If anyone can help me out I will be very grateful! Thanks in advance.
Altman
For info here are the triggers in XML:
Trigger 1:
Code: |
<trigger name="Short_future" type="Within Lines" param="1" priority="13210" id="1321">
<pattern>c price *</pattern>
<trigger type="Within Lines" param="1">
<pattern>+++ The exchange display shows the prices for (%w) +++</pattern>
<value>#var Fut_Temp %lower( %1)</value>
</trigger>
<trigger type="Within Lines" param="1">
<pattern>+++ Exchange has (%d) tons for sale +++</pattern>
</trigger>
<trigger type="Within Lines" param="1">
<pattern>+++ Offer price is (%d)ig/ton for first 75 tons +++</pattern>
<value>spotprice = (%1 / 1.1)
spread = (%db(%db(@products,@fut_temp), cprice) - @spotprice)
#echo @Fut_temp spread is @spread
#if (@spread > 20) {#echo buy @Fut_temp} {}
doprice</value>
</trigger>
</trigger> |
Trigger 2:
Code: |
<trigger name="Mixed_future" type="Within Lines" param="1" priority="13210" id="1369">
<pattern>c price *</pattern>
<trigger type="Within Lines" param="1">
<pattern>+++ The exchange display shows the prices for (%w) +++</pattern>
<value>#var Fut_Temp %lower( %1)</value>
</trigger>
<trigger type="Within Lines" param="1">
<pattern>+++ Exchange has (%d) tons for sale +++</pattern>
</trigger>
<trigger type="Within Lines" param="1">
<pattern>+++ Offer price is (%d)ig/ton for first 75 tons +++</pattern>
<value>#var mix_sell %1</value>
</trigger>
<trigger type="Within Lines" param="1">
<pattern>+++ Exchange will buy 75 tons at (%d)ig/ton +++</pattern>
<value>#if (%db(%db(@products,@fut_temp), Term) = Long) {
spotprice = ((%1 + @mix_sell)/2)
spread = (@spotprice - %db(%db(@products,@fut_temp), cprice))
#echo @Fut_temp spread is @spread
#if (@spread > 20) {#echo buy @Fut_temp} {}
doprice} {
spotprice = ((%1 + @mix_sell)/2)
spread = (%db(%db(@products,@fut_temp), cprice) - @spotprice)
#echo @Fut_temp spread is @spread
#if (@spread > 20) {#echo buy @Fut_temp} {}
doprice }
</value>
</trigger>
</trigger> |
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Apr 05, 2010 4:56 pm |
1)Within Lines defines the current line within the context of previous lines. For example, WithinLines|param=1 means you want this state to match only when it occurs as the next line after the previous state. It doesn't make sense to use it as the initial state type, so you probably want command input as the type for that state.
2)Delete the first trigger. The two sets of triggers match on the same lines, and the only difference is the inclusion of a not-always-there line at the end which the second trigger already handles. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Mon Apr 05, 2010 6:19 pm |
Thanks for the help Matt. Both of those suggestions make sense.
If I use only the second trigger, how do I stop it from firing when it reaches the 3rd line of example text 2? I need the triggers to do something different when they receive example text 1 vs. example text 2. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Apr 05, 2010 6:37 pm |
Change the fourth line to match the fourth line from both examples. You can then process this pattern result to see which you ended up with. The code from your 3rd-line conditions would be moved to this 4th-line condition, and would be executed based on the pattern result of this 4th line.
#condition {^(whatever matches both examples)$} {
#if (%1 = "whatever matches example 1's fourth line") {do example 1 code from 3rd-line condition here} {do example 2 code here}
} |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|