Author Topic: Constants vs. user variable  (Read 4557 times)

Tags:
  • Élite
  • Posts: 110
*
Constants vs. user variable
« on: 04 Jun 2013, 08:03 »
Hi,

A quick question with regards to usability.

Is there any difference between defining a constant (as an user variable) or using the function "set user variable" within the trigger editor?

I'm always defining constants. Are there situations where it makes more sense to use the function "set user variable"

I appreciate any comments.

Cheers,
bamthwok

  • Administrator
  • Posts: 8821
  • Gender: Female
*
Re: Constants vs. user variable
« Reply #1 on: 04 Jun 2013, 08:52 »
Hi bamthwok,

The difference between a constant and a variable is that a constant has its value set before you even launch any of the triggers. However, in all other respects it works exactly like a variable.

I would prefer creating a constant to creating a variable if that is what your betting plan allows.

The only case when you would specifically need to create a variable is when you need to assign it a value of another trigger variable or a trigger expression. In that case creating a constant will not work as you can only give them numeric or text values.
Always try your triggers in Test Mode before switching to real money!

Follow us on Twitter.

Join our WhatsApp chat!

Присоединяйтесь к официальному Telegram-каналу!

  • Élite
  • Posts: 110
*
Re: Constants vs. user variable
« Reply #2 on: 04 Jun 2013, 09:20 »
Hi Oxa,

Thanks for quick reply.

Can you please give me an example (maybe from existing trigger library) where you need to create a variable.

Please also advise at what point the value of a user variable can be monitored via the user variable tab of the program.

In my case I can see values of constants but not those of user variables.

Cheers,
bamthwok


  • Élite
  • Posts: 3698
  • Gender: Male
*
Re: Constants vs. user variable
« Reply #3 on: 06 Jun 2013, 20:03 »
hi bamthwok
to see the value of a variable
open the variable screen (top centre of the bot screen with the paper clip)
now type in the first column your variable name that you want to see the value.
so if you want to see the value of the second favourites last traded, you would type.
r_2_last_traded
you will now see the value of the 2nd favs last traded price
you can do this for any variable, user or mfp pre set variables

a constant(variable) is what it says, the value is fixed(constant), the only way to alter these is to alter them manually then reload the trigger, or if you want the constant to remember a last value, then you have to alter the value with a trigger, then when the bot is shut down, the constant takes on the new value in the constants.


mcbee
Please read the following  disclaimer with regards to the information you may request and obtain on our forum. This specifically concerns trigger files and various instructions as to how to implement a strategy.

  • Élite
  • Posts: 110
*
Re: Constants vs. user variable
« Reply #4 on: 07 Jun 2013, 18:03 »
Hi McBee,

Thanks for your reply.

However, my observation is a little bit different.

A constant is not really a constant but changes value. For example I can create a constant in the trigger editor by using a formula. The value is being updated with every refresh (if looking at it at the variable screen).

A user variable (created via "set user variable" ) is only updated once a trigger is being monitored .

For example: if I set a condition "Market's Minute before the Off is less than 1" then the constant will show the value at the variable screen anytime once the market is being monitored but the user variable will be set only one minute before the off.

But as Oxa said, only a user variable can hold a trigger expression as a value; a constant can't.

That's my understanding.

Cheers,
bamthwok

  • Administrator
  • Posts: 8821
  • Gender: Female
*
Re: Constants vs. user variable
« Reply #5 on: 07 Jun 2013, 18:07 »
the only way to alter these is to alter them manually then reload the trigger

No, not quite mcbee. You can change the value of a constant through a trigger's "set user variable" action. I know this sounds controversial, but that's how it is in the program.
Always try your triggers in Test Mode before switching to real money!

Follow us on Twitter.

Join our WhatsApp chat!

Присоединяйтесь к официальному Telegram-каналу!

  • Administrator
  • Posts: 8821
  • Gender: Female
*
Re: Constants vs. user variable
« Reply #6 on: 07 Jun 2013, 19:33 »
But as Oxa said, only a user variable can hold a trigger expression as a value; a constant can't.

That's right, when you're adding constants through the "Add Constant", you can't put a formula or a trigger variable in the value field.

But you can change the value of the constant through a trigger, and in that trigger you can assign it all sorts of trigger variables and formulae.

To give you a simple example. When you program a staking plan, you want to create a constant which will hold the size of the initial stake, for instance init_bet. It is normally a number of your currency units, e.g. 2.
But then you may need a variable that holds the value of the current bet size. This variable can change from market to market, depending on the previous loss. Also, this variable's initial value must be equal to the constant that denominates the initial stake. So you create a trigger that "sets user variable", let's say, current_bet, and its value will be equal to init_bet.

This is an example of when you need specifically a trigger variable, and not a constant. The variable current_bet is initialised with a constant, and so it can't be a constant itself.

I pray that you did understand my ramblings!
Always try your triggers in Test Mode before switching to real money!

Follow us on Twitter.

Join our WhatsApp chat!

Присоединяйтесь к официальному Telegram-каналу!

  • Élite
  • Posts: 3698
  • Gender: Male
*
Re: Constants vs. user variable
« Reply #7 on: 07 Jun 2013, 21:51 »
hi
i did say.
a constant(variable) is what it says, the value is fixed(constant), the only way to alter these is to alter them manually then reload the trigger, or if you want the constant to
Quote
remember a last value, then you have to alter the value with a trigger, then when the bot is shut down, the constant takes on the new value in the constants.
what i was trying to say is that if you look at the constants in the trigger editor when the bot is running, you will not see the change of value.


mcbee
Please read the following  disclaimer with regards to the information you may request and obtain on our forum. This specifically concerns trigger files and various instructions as to how to implement a strategy.

  • Administrator
  • Posts: 8821
  • Gender: Female
*
Re: Constants vs. user variable
« Reply #8 on: 08 Jun 2013, 09:55 »
a constant(variable) is what it says, the value is fixed(constant), the only way to alter these is to alter them manually then reload the trigger, or if you want the constant to what i was trying to say is that if you look at the constants in the trigger editor when the bot is running, you will not see the change of value.

That's right mcbee, spot on.
Always try your triggers in Test Mode before switching to real money!

Follow us on Twitter.

Join our WhatsApp chat!

Присоединяйтесь к официальному Telegram-каналу!

 

Please note, BetFair is seems to be currently OFFLINE