Syntax for capturing previous bid/ask in Easylanguage
I am brand new to EasyLanguage, so struggling to find a simple syntax.
Example below identifies he problem in detail:
Problem 1) I currently am looking at a 1 min chart window and see the price on @ESM16 go
from $2115.00 to $2114.75.
I am trying to code a logic that will identify the previous price of $2115.00 and current price of $2114.75 and put them in two different variables. Then compare the variables to see which one has a greater numeric value.
I know this is basic easy language stuff, but I am new to Easylanguage so please understand.
EasyLanguage code is executed from top to bottom, therefore you can save an old value before overwriting it like this:
Now the variable myOldValue will hold the value that was last stored (during the last code cycle) in newValue and newValue will hold the value that Close currently has.
You might also want to look into "intrabarpersist", what it does and if you might need it for your solution.
By the way you can show your appreciation for a post here on Futures.io using the "Thanks" button under it.
The following 2 users say Thank You to ABCTG for this post:
ABCTG, your answer really helps. Thanks a bunch, but this puts another question in my mind.
The reserved word "Close", does it take the closing price of the previous bar? I think so right?
if so, then I need a strategy that picks up the previous price, whether it happened in the last minute or whether it happened in the last Nano second and not necessarily from the closing price from the previous bar.
Does intrabarpersist give me the ability to pick up that price that came immediately before the current price?
Also I need to figure out a way to capture the current price, compare this with previous price and then compute whether the price went Down 0.25 or went Up 0.25 (strictly monitoring the minimum price move "direction" for S&P Emini in 0.25 increments)
Maybe I can format my charts to "Kase Chart" and make the target value range as 0.25 ? Maybe this is not the right solution...I am confused here.
Thanks so much for helping!
The following user says Thank You to mashficool for this post:
sometimes it helps to print the values of a variable or reserved word to see what value it holds.
Close will return the last price a trade took place at.
That's why the code snippet I posted could be used to compare the last two ticks (or better the last two values close had while your code was executed) provided the two variables are intrabarpersist and your code is executed intrabar.
Yes, `Close` returns the closing price of a bar: `Close` returns the current bar's closing price, `Close` of the previous bar, and `Close` of the bar before that, and so on.
There's one exception to this, and that's when the bar that the script currently calculates on is still being updated (that is, it's a real-time bar and ticks are still incoming). In that case, `Close` refers to the current, most recent tick.
If you mean with 'price' the closing price, you can do that like:
You may of course adjust your charts if you want to, but it's not needed per se since it can also be done with code (and so you can keep the chart like you want it).
The following user says Thank You to Jura for this post:
Do I have to use Intrabarpersist = true in this code above that you gave me? or will it work without it? I am still learning the Intrabarpersist thingy in easylanguage.
When you write a script to take a position when certain conditions occur,
("if this = this and this.. then do that") how do you make sure the script does not keep taking new positions? is there a reserve word in easylanguage for that ? in ninjatrader topic here in this forum, I found the word to be EntriesPerDirection but such words does not exist in easylanguage..