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)
Here's my goal. If condition1 then just wait until condition2 happens, then sell short.
I've been researching if...then..begin, if..then...if then..begin, once, while, and many combinations and a few others. Been playing with it for a long while. I can't get it to work.
Here's a code sample.
if condition1 begin if condition2 then sellshort
Any help would be appreciated.
Thanks,
Ryan
Can you help answer these questions from other members on NexusFi?
Somebody, perhaps @ABCTG, who knows what they are talking about in EasyLanguage, will probably give you a better-informed answer, but until they come along, here's my take (as a programmer, but not an EL programmer.):
Usually when a language has a begin and end construct, it sets up a block, and you will want to use that block structure in your logic. So I suggest you try something like this, which nests the conditions within different blocks (if I don't have the correct syntax for an if statement in EL, such as whether it needs a "then" or something, I'm just trying to illustrate how to do the blocks. You may have to change something to fit how EL actually does things.)
What this is intended to do is (1) if thing1 is true, then (2) check if thing2 is also true, and do something if so. Otherwise, just skip it:
You can see that the "outer" begin/end block is for the first condition and anything that is executed if thing1 is true. The "inner" begin/end block is what happens if thing2 is true. If you have an "if", you need a "begin", some code, and an "end". If you have another condition within that first "if" block, then the second "if" needs its own complete block. As I said, this is not necessarily literal EL code, just an illustration of how to do the blocks, assuming EL is like other block-structured languages.
I hope this works, and I hope I understood you correctly. If not, just wait for someone who actually codes in EL and knows what he's doing in it.
Bob.
When one door closes, another opens.
-- Cervantes, Don Quixote
apart from your problem I would suggest using meaningful variable names as this will make your programming life much easier in the long run.
Do not use generic variables like Value1 or Condition1 as these make your code much harder to read.
You could use a boolean variable that you set to true when you first condition occurs and then include this variable in a check for your second condition that includes your actual order conditions.
Depending on your preference you could only do this while you are flat or not yet short as this would prevent situations where the variable is set while you are already in a trade.
When you are filled or when you issue the order you set this boolean variable back to false.
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207
Nice explanation Bob.
Maybe not relevant to this specific question but I find that when multiple (non-nested) IF statements are involved, often SWITCH & CASE can clean the code up considerably.