Store a Value for further calculations
-
Hello Experts,
I want to store a value.For example we have no trade.
As soon we activate the bot, I want to store the value of difference of Ask price and Bid price (Spread) at that moment. further I have to do a calculation with that fix stored value.Please suggest how to do this
-
@Mani13 You can use a variable to store that. Like this:

-
@l-andorrà , Thanks you stepping in.
Actually this is what I want to store but I am not able to get a fix value, it is keep on fluctuating.
A fix value of difference open is needed to store when bot is activated

-
@Mani13
I am afraid the it is the spread you are talking about. It probably not a fix value and depends on the time you run this block. -
@sktsec Yeah it is not a fix value, and this is the task which I am trying to do just to get a value when bot just activated or after closing the previous trade.
-
Are those 'Pair_1' and 'Pair_2' of a string type? Otherwise it will not work.
-
@l-andorrà Yes,
Infact i am getting the variable value perfectly. I just want any of a fix value of any moment when there is no trade open, for now it keep on changing as price fluctuates -
@Mani13
If you mean to record the spread on every tick data, that seems to a big task. Better find a way to get the tick data history (with spread) from your broker -
@sktsec That is not the spread actually, I want to record the difference between bid and ask price of 2 different pairs with similar decimal value.
I dont want to record every tick data. just need 1 numeric value of any time when there is no trade
-
Isn't the difference between bid and ask price the definition of spread?

-
@l-andorrà Actually it is bid of other pair and ask of another pair.
for example BID of USDCAD pair - ASK of GBPUSD pair.BID 1.3710 - ASK 1.3590 = 0.0120
Need to store this value (0.0120) of their difference when no trade is there,
-
That means you successfully got the value.
In case you aim at a particular value at a particular time, have you tried Block pass once ? Does it help ?
-
@Mani13 This is the way to do that:

-
i love it !
-
Thank you.

-
@l-andorrà This I done as you said but that value is keep in fluctuating, How can i fetch a fix value then ignore that variable
-
The value will always be fluctuating because both price levels will be fluctuating too. When do you want to get a fixed value exactly?
-
@l-andorrà I need the value at any time when there is no trade, either at starting of the bot or after closing the previous trades.
Actually I want that value for the reference for futher entry and exits -
But the value will change through time before a new trade is open. How can you know the value that was stored 1 hour ago is still valid now?
-
@l-andorrà Actually the trade will open according to that reference value that being stored. so it doesnt matter how old the value is