How to Use "IF"

traderjz19

Newbie
Messages
4
Likes
0
Hi, I have a question about the IF statement.

I want to write an IF statement where if X is true, buy (aka execute condition A), otherwise execute condition B.

What is the correct way to write it?

Thanks a lot!

J
 
That depends on the programming language.

C#:

If (a>b) { System.Diagnostics.Debugger.Break(); } else { System.Diagnostics.Debugger.Break(); }

Every proper programming language comes - you know - with a DOCUMENTATION that one can read to get questions like this answered.
 
THen metastock should have documentation.

I normally do not mind people asking questions, but if it is on the level of "I am too lazy to look up the documentation" that is something I personally find a little offensive.

I suggest you grab your docu, open it, find the descriptio nof the "if" function (most likely a function, not a statement, iirc) an if you THEN still have problems, ask again ;)
 
OK so I am assuming you have not got a pirated version or you lost the instruction book for Metastock

=if(condition a,then condition b, otherwise c)
 
Thanks guys. Sorry for not being clearer before, I do know the IF function, but I just don't know how to write if a condition is true "BUY" otherwise "SELL". How do you write buy and sell in the function?
 
Thanks guys. Sorry for not being clearer before, I do know the IF function, but I just don't know how to write if a condition is true "BUY" otherwise "SELL". How do you write buy and sell in the function?

Buy := your code for condition A;

Sell := your code for condition B;

X := your code for X;

If(X,Buy,Sell) {reads as if X, is true then Buy, is false then sell}
 
if(conditionA,"buy","sell",0).

When u using text in e xcel you have to start and end with the thingymejigs,cant remember what they are called, :)
 
I'm only familiar with the strategy module, where if isn't necessary, if a statement is true, it will trigger the action for the section you're in (long, sell to cover, short, buy to cover). But you can use it

if(rsi(2)>80,1,0)
same as
rsi(2)>80
 
I'm only familiar with the strategy module, where if isn't necessary, if a statement is true, it will trigger the action for the section you're in (long, sell to cover, short, buy to cover). But you can use it

if(rsi(2)>80,1,0)
same as
rsi(2)>80

manatrader, your comments are spot on as the If function is definately not a requirement for initiating a Buy or Sell Order in the Enhanced System Tester.:whistling
 
Hi guys, thanks for the replies, very helpful.
So if I do use the IF function, and putting in a 1 for true and a 0 for false, does it actually initiate a Buy and Sell order respectively?
 
Hi guys, thanks for the replies, very helpful.
So if I do use the IF function, and putting in a 1 for true and a 0 for false, does it actually initiate a Buy and Sell order respectively?

If you are referring to the Buy & Sell Orders in the Enhanced System Tester you would be better off following manatraders recommendation.

Under the Buy Order tab put in your code to go long and viceversa for your Sell Order.

To get an idea of what is expected have a look through the code etc. of one of the systems included in the software.
 
Top