variables vs contants
-
this might be a basic topic to some of you but I'm pretty confused on how/when to use a variable when it seems like a constant will do the same thing. I get that variables are just that "variable" but how is a constant that I can "vary" the value of in my EA not variable as well. what is an example that I would need to use a variable over a constant?
-
You change constants, computer changes variables.
Constants are constant from the computer's viewpoint
-
Ive watched some videos on the use of variables in fxdreema but the use/placement of them within blocks didnt make any sense to me.
if for example I am trying to create something like a donchain upper and lower channel by reading the high and low within a period of candles and then display that on the chart how could i use a variable to keep up with those changes? -
@speedsk8r if you want to take some chart value and store that value, a variable is always the way to go.
Maybe this helps
https://fxdreema.com/tutorial/builder/constants-and-variables -
i see a block that uses "new top in trend and new bottom in trend. how could i display that on a chart like a donchain line? could i just use those blocks and create a variable for use within those blocks?
-
yes ive seen and read through that link. i can see that I can create and apply a variable like a constant to a given block but how do I know what that variable is reading on the chart if its automatically going to change values. what determines what data that variable is getting?
-
for example in the "new top on trend" block it has 3 parameters that all seem to be fixed values. if i want to use a variable to read the new top in the trend how would i go about that?
-
@speedsk8r that is probably not the right block for you. The block gives you a yes/no answer, not a price level.
Its probably better for you to use modify variables block and then select highest/lowest price from market properties.

-
ahh ok i see! so... i see that block is using the market properties to get the highest price within a period of candles id start id end. if its already doing that then what do I use as the variable input above?
-
The value will be stored in that variable so you can use it later.
-
ahh ok i see.. so then if the retrieved value is the variable what do I attach the output of that block to? does the output of that block do the same thing as the value stored in the variable? is the proper way to let that block stand alone in my workspace and not attached to anything else?
-
@speedsk8r well that depends on your project, what you are trying to accomplish...
But in general, you should connect everything on one chain so the proper order is ensured; you should first update your variable and then use it, not try to use a variable before it has a value.
-
yes I understand that logic. I need the value before I can display it on the chart as an object or line. I think I also understand that variables are retrieved values from the operations of a specific block. Im trying to lastly understand that in order to use that retrieved variable do I need to have that block connected to something or will it read the changing values anyways and I can just apply that variable to anything else connected or otherwise.
for example.. if I want to buy when a new high is made by the upper donchain and a new high is made by the lower donchain it seems like I would need to connect that block to an order block or a series of blocks responsible for my order flow. -
up until right now I've never noticed to the modify variables block! A big discovery for me and a source of my consternation on understanding this topic. thank you for the help Roar!
-
if the value of a variable is "retrieved" by the system then should I not be using my own value when creating them? If I do use a value then how do I determine what that value is? wont that value be changed even if I set it preliminarily?
-
@speedsk8r when you create a variable, usually it gets a default value of 0 unless you specify something else. The default value doesnt matter, the system will replace it anyway.