Problem with SV (when calculating formulas with negative and previous values)

Advanced automation available in Guardian - Chat with others and share files here.
Post Reply
gaz36f
Posts: 16
Joined: Mon Nov 30, 2020 7:52 am

I have made a total hash of this.

I have understood (I think) sniffer66's point about ABS values and I have managed to remove the signals and incorporate the suggestion into these new set of rules.

I have tried, very hard, to go through each of goat68's steps but, sadly, I have failed abysmally. Whilst I thought I had understood how signals/SV's worked relatively well, I clearly don't. I cannot get my head around:

1. PreviousLTP - is this not the same 'chicken and egg' problem I have with PreviousATR in the ATR equation? I have set it up as a SV with LTP, but I am assuming this is wrong.

2. Resets - I have tried to work out why these values need resetting if they change on each iteration of the 'count'. I know there will be an explanation but I can neither think of one or find one in the forum.

3. Step 4.

These are the rules I have created so far:
Screenshot (116).png
I have attached the baf file. Goat68, would you very kindly take a look and let me know where I am going wrong?

Many thanks, Gary
ATR New.baf
You do not have the required permissions to view the files attached to this post.
User avatar
goat68
Posts: 2019
Joined: Tue Jun 30, 2020 3:53 pm
Location: Hampshire, UK

gaz36f wrote:
Wed Feb 10, 2021 7:57 am
I have made a total hash of this.

I have understood (I think) sniffer66's point about ABS values and I have managed to remove the signals and incorporate the suggestion into these new set of rules.

I have tried, very hard, to go through each of goat68's steps but, sadly, I have failed abysmally. Whilst I thought I had understood how signals/SV's worked relatively well, I clearly don't. I cannot get my head around:

1. PreviousLTP - is this not the same 'chicken and egg' problem I have with PreviousATR in the ATR equation? I have set it up as a SV with LTP, but I am assuming this is wrong.

2. Resets - I have tried to work out why these values need resetting if they change on each iteration of the 'count'. I know there will be an explanation but I can neither think of one or find one in the forum.

3. Step 4.

These are the rules I have created so far:

Screenshot (116).png

I have attached the baf file. Goat68, would you very kindly take a look and let me know where I am going wrong?

Many thanks, Gary

ATR New.baf
sure np, I should have some time this evening to take a look
gaz36f
Posts: 16
Joined: Mon Nov 30, 2020 7:52 am

Thanks Goat68. Much appreciated.
User avatar
goat68
Posts: 2019
Joined: Tue Jun 30, 2020 3:53 pm
Location: Hampshire, UK

gaz36f wrote:
Wed Feb 10, 2021 7:57 am


ATR New.baf
Hi Gary,
I'm just looking at your baf file, some notes:
"hi/lo SVs" rule:
You're setting hi & lo to the High Traded Price, however that is not quite what you want, as that is the High/Low since the market opened...whereas you want the high/low for the current 10second TR period. What you need is to on your 10second timer reset your hi/lo to the current LTP. Then have 2 rules one for hi one for lo, which has a condition if current LTP > hi then update hi SV, and a lo rule if current LTP < lo then update lo. Then at the next 10second timer they get reset to currentLTP, etc etc

timer rule:
This needs to be slightly different,as you need to "signal" to the following rules which will then reset the signal once processed, and also keep count. So have the signal say called "timer_trigger", and in the same rule also increment the "count" as a SV (count = count +1)

For each timer count<15:
So the Conditions for this is now 2 lines: "timer_trigger" set and SV "count"<15
In SV actions:
PreviousPeriodLTP can just be set to Current LTP at the "end" of the SV actions, as this has just triggered at the end of the period, so the closing period price for the current period is the current LTP. You will need to init the 1st PreviousPeriodLTP to lo or hi, doesn't matter which, add another rule with same trigger before this one with if count=1 set PreviousPeriodLTP=hi.
In your Ending TRs rule calculate both Hi-PreviousPeriodLTP & PreviousPeriodLTP-Hi, ditto Lo, then in your following 4 SumTr rules make the Condition on these values which are >0, to achieve your Abs() function, note your range function needs to be "Max of values".
You also need a different "trigger" condition as they are going to trigger every refresh as they are. You just want "timer_trigger" set and SV "count"<15, same as previous rule.

You also need both a 14th and a <14th period rules both triggered by: "timer_trigger" set and SV "count"=14/<14 as well. BOTH these in their Signal tab need to Clear "timer_trigger", so you can see this signal has triggered all the above rules on this event, but you must now clear it otherwise it will just run this rule again on next refresh.

I suggest trying to get the above bit working first, ie.you get your 1st ATR calculated after 14 10second periods correctly. Utilise logging to check the results.

I hope that helps to start with, this is a tricky one to do, but progress stage at a time is the best way to get there. Once you have the above working progress to the >14period ATR calculation... I can help you there if you need.
Cheers
Goat
gaz36f
Posts: 16
Joined: Mon Nov 30, 2020 7:52 am

Hi Goat, thanks very much indeed for all your help and guidance with this. I thought I would hold off responding until I had 'finished' it. Anyway, it is taking much longer than I thought as I trying to read up more about signals and the implementation of timer rules. I want to ensure I fully understand each step so any subsequent bots will be easier to write. Hopefully I'll post the working bot in this thread in the next couple of days. Cheers, Gary
gaz36f
Posts: 16
Joined: Mon Nov 30, 2020 7:52 am

Hi Goat,

I am again stuck on how signals works. I have tried to understand every step on this rule before moving onto the next and have been reading / making notes on areas I have not quite got. That said, I think I got this rule working at some point but messed it up again. I think it is something to do with the timer_trigger as all the values now keep getting zeroed out. I suspect it is because I cannot really get my head around this part:
You also need both a 14th and a <14th period rules both triggered by: "timer_trigger" set and SV "count"=14/<14 as well. BOTH these in their Signal tab need to Clear "timer_trigger", so you can see this signal has triggered all the above rules on this event, but you must now clear it otherwise it will just run this rule again on next refresh.
I have attached the new .baf file but I feel a bit cheeky pestering you with this, so please only take a look if you don't mind. I genuinely wanted to do it all myself (not least because it is the best way to learn), but I think I have hit my current limits of understanding/ability. :(

Very best, Gary
ATR New2.baf
Post Reply

Return to “Bet Angel - Automation”