how to automatically record markets in a quick list

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 10:27 am

Sorry for being a simpleton, I'm just struggling to visualise looping using live data.

You understand what I mean though dont you ?

How would I wrap the code in a for loop?
As in

If old Price = 2 higher than new price then
Log
Elseif old price = 2 lower than new price then
Log
Elseif old price =4 higher than new price then
Log
Elseif old price = 4 lower than new price then
Log
Etc etc (this is how I currently have it set, as you can imagine its bloody long ha ha
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby Captain Sensible » Wed Sep 30, 2020 10:50 am

Because you know you're increasing in steps of two you can replace the numbers in your code with x and then we step up in 2's, so to start x is 2 then x is 4 then x is 6 and so on until you reach the maximum number of ticks to log

For x = 2 to x step 2

If old Price = x higher than new price then
Log
Elseif old price = x lower than new price then
Log

next x
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 11:07 am

Ok I will create a dummy sheet and have an experiment. I just cant visualize it.

For example if x equals 6 for example

I want it to log
2 (volume 0)
4 (volume 0)
6 (volume = current matched amount)

If x equals 2 then just simply
2(volume = current matched amount)

Its so the chart plots accurately
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby Captain Sensible » Wed Sep 30, 2020 11:35 am

Gimme a few minutes and I'll tweak the earlier code as an example you ca stick in a sheet and fiddle with until you grasp the logic behind it.

It's a lot to learn if you haven't done much coding and you might be better off just getting one of the coders on the site to write it for you as it'd be a lot more efficient and to spec. I could code probably it but I don't have the time or the experience the coders on here have so can only give you odd pointers. The user Osknows is very well regarded and experienced on here if you do need a coder. viewforum.php?f=12
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: how to automatically record markets in a quick list

Postby Captain Sensible » Wed Sep 30, 2020 11:56 am

Code: Select all
Sub floor()
Dim i As Integer, end_of_loop As Integer
Dim direction As String: direction = ""
Dim old_price As Currency, new_price As Currency, volume As Currency

old_price = 2.2
new_price = 2.02
volume = 50

i = getTicks(old_price, new_price)
If i >= 0 Then direction = "up"
i = Abs(i)
end_of_loop = WorksheetFunction.floor(i, 2)



For i = 2 To i Step 2

    If direction = "up" Then
        Worksheets("Sheet1").Range("A" & 15 + i / 2).Value = "Recording price " & plusTicks(old_price, 2)
    Else
        Worksheets("Sheet1").Range("A" & 15 + i / 2).Value = "Recording price " & minusTicks(old_price, 2)
    End If

    If i = end_of_loop Then
    Worksheets("Sheet1").Range("C" & 15 + i / 2).Value = volume
    Else
    Worksheets("Sheet1").Range("C" & 15 + i / 2).Value = 0
    End If

Next i
End Sub



So all the code does is get the number of ticks between the prices (i) ,
then decides if the direction is up or down (direction) ,
we then get the absolute value of i so we can loop (so it's not negative) ,
then use floor to get the last ticks we want to record as you only want it in multiples of 2 (end_of_loop)

Now loop thru the number of ticks in steps of 2
if the direction is up we add 2 ticks to the price (plusticks), if down we take off two ticks (minusticks)

if our loop reaches the end_of_loop i.e the last number of ticks you record we dump the volume, if it's nt the last number we dump 0 to the sheet.

All values will be sent to A15:C15 down as i just did it on a test sheet .
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: how to automatically record markets in a quick list

Postby Captain Sensible » Wed Sep 30, 2020 11:57 am

Most of it is just setting variabes and the loop is only

Code: Select all
For i = 2 To i Step 2

    If direction = "up" Then
        Worksheets("Sheet1").Range("A" & 15 + i / 2).Value = "Recording price " & plusTicks(old_price, 2)
    Else
        Worksheets("Sheet1").Range("A" & 15 + i / 2).Value = "Recording price " & minusTicks(old_price, 2)
    End If

    If i = end_of_loop Then
    Worksheets("Sheet1").Range("C" & 15 + i / 2).Value = volume
    Else
    Worksheets("Sheet1").Range("C" & 15 + i / 2).Value = 0
    End If

Next i
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 1:03 pm

Thanks Captain

this is very much appreciated! i will have a play with this until i understand it, hopefully i will grasp it
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 1:18 pm

I get that!!!!! thanks loads Captain!!! I will be able to make that work !!
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 1:28 pm

i see that all those functions you sent me are linked
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 1:39 pm

also why is there no end if for line If i >= 0 Then direction = "up"?
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby Captain Sensible » Wed Sep 30, 2020 2:45 pm

cjones198 wrote:also why is there no end if for line If i >= 0 Then direction = "up"?


You can write it like below if it's easier for you to understand but if the condition is simple you can include the TRUE condition straight after the THEN to save lines

Code: Select all
If i >= 0 Then
direction = "up"
End If


If the condition was true and more things needed to be done you'd write it as above so it's easier to read and understand say

Code: Select all
If i >= 0 Then
direction = "up"
something_else="yes"
End If
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: how to automatically record markets in a quick list

Postby Captain Sensible » Wed Sep 30, 2020 2:52 pm

And forgot to mention we'd already set direction to nothing in the line

Code: Select all
Dim direction As String: direction = ""


so there was no need for an Else in the If statement. The colon just saves us having put it in two lines also as it could have been

Code: Select all
Dim direction As String
 direction = ""
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Wed Sep 30, 2020 9:03 pm

Thanks Captain!
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Thu Oct 01, 2020 5:51 am

sorry to bother Captain why doesn't this work?

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Static i As Integer, end_of_loop As Integer
Static direction As String: direction = ""
Static old_price As Currency, new_price As Currency, volume As Currency
Static iCol As Integer

iCol = 4
old_price = Sheets("Sheet1").Cells(1, 1).Value
new_price = Sheets("Sheet1").Cells(2, 1).Value
volume = Sheets("Sheet1").Cells(3, 1).Value

i = getTicks(old_price, new_price)
If i >= 0 Then direction = "up"
i = Abs(i)
end_of_loop = WorksheetFunction.floor(i, 2)



For i = 2 To i Step 2

If direction = "up" Then
Worksheets("Sheet1").Cells(10, iCol + i / 2).Value = " " & plusTicks(old_price, 2)
Else
Worksheets("Sheet1").Cells(10, iCol + i / 2).Value = " " & minusTicks(old_price, 2)
End If

If i = end_of_loop Then
Worksheets("Sheet1").Cells(11, iCol + i / 2).Value = volume
Else
Worksheets("Sheet1").Cells(11, iCol + i / 2).Value = 0
End If

Next i

iCol = iCol + 1
End Sub
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: how to automatically record markets in a quick list

Postby cjones198 » Thu Oct 01, 2020 10:27 am

Sorted that! silly error hadnt put application.enable events in!
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

PreviousNext

Return to Discussion

Who is online

Users browsing this forum: No registered users and 14 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.

cron