Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
Regards,
Mash
Can you help answer these questions from other members on NexusFi?
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.
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.
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.
The reserved word "Close", does it take the closing price of the previous bar? I think so right?
Yes, `Close` returns the closing price of a bar: `Close` returns the current bar's closing price, `Close[1]` of the previous bar, and `Close[2]` 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.
mashficool
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)
If you mean with 'price' the closing price, you can do that like:
Variables:
priceDifference(0);
priceDifference = Close - Close[1];
if (priceDifference = 0.25) then
Print("Up 0.25 points")
else if (priceDifference = -0.25) then
Print("Down one 0.25 price increment");
mashficool
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.
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).
Yes, `Close` returns the closing price of a bar: `Close` returns the current bar's closing price, `Close[1]` of the previous bar, and `Close[2]` 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:
Variables:
priceDifference(0);
priceDifference = Close - Close[1];
if (priceDifference = 0.25) then
Print("Up 0.25 points")
else if (priceDifference = -0.25) then
Print("Down one 0.25 price increment");
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).
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..