logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
dionusos1  
#1 Posted : Saturday, February 3, 2007 6:03:03 PM(UTC)
dionusos1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/6/2007(UTC)
Posts: 6

Hello,

I would like to know which of the 3 conditions below is true or false

If(c>ref(c,-1),1,0) +

If(v>50000,1,0) +

If(Rsi(14)>50,1,0)

If the result is the number 3 or 0 = all conditions are true or false, but if the number is 2 or 1, I don’t really know which of the 3 conditions is false or true.

If the conditions numbers is relative small (like the above example) I could write the same formulas like:

A) If(c>ref(c,-1), 1, 0) +

B) If (v>50000, 2, 0) +

C) If (Rsi (14)>50, 4, 0)

and all the possible results, would be 8 combinations

Where:

0=A+B+C (All false)

1=A true (B and C false)

2=B true (A and C false)

3=A+B true (C false)

4=C true (A and B false)

5=A+C true (B false)

6= B+C true (A false)

7=A+B+C (All true)

So my question is: If I have a big number of conditions (10 or 20) is there a way to create a code (via FML language) in order to find out true or false conditions?

Thanks in advance

Dionusos

hayseed  
#2 Posted : Saturday, February 3, 2007 7:13:45 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey dion..... for small numbers of conditions rather than adding things up, which just requires dividing them back out , you could simply plot them as a indicator.... using 1 , 2 and 3 for the values it , just a quick glance would show which a positive....

your question was about large number of conditions where the above would no way work..... in that case use the 'write if' to make a comentary in a simple expert.... that is taylor made for your task..... the expert would not have to attached to anything to work ..... are you familar with it..... h

/// small number of condions only/////

---------------------------------------

a:=If(C>Ref(C,-1),1,0);
aa:=If(V>50000,2,0);
aaa:=If(RSI(14)>50,3,0);

a;aa;aaa;

------------------------------------

dionusos1  
#3 Posted : Sunday, February 4, 2007 4:34:24 AM(UTC)
dionusos1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/6/2007(UTC)
Posts: 6

Thanks hayseed for your quick replay,

I am now getting into the details of my code.

Example:

Cond1:=If(C>Ref(C,-1), 1, 0);

Cond2:=If(V>50000, 2, 0);

Cond3:=If(RSI(14)>50, 4, 0);

cond1 +cond2 +cond3

At the above example with 3 conditions, I use decimals output numbers (1, 2, 4), but the addition of these decimals numbers, easily could be transformed to binary ones.

I can do that if I open the Microsoft calculator and write the number 7. Then I select View => Scientific mode => binary.

So if the result equal to 7, the corresponding binary number, equal to (1, 1, 1) => all true.

If the result equal to 5, the corresponding binary number, equal to (1, 0, 1) => cond1 +cond3= true but cond2 = false. (We read from the right to the left).

If we have 10 conditions and the decimals output corresponding numbers are: (1,2,4,8,16,32,64,128,256,512) the addition of all these numbers equal to 1023 and this one equal to the binary number 1,1,1,1,1,1,1,1,1,1. So all conditions are true.

But if the result is 1022 the corresponding binary number is 1,1,1,1,1,1,1,1,1,0 and that means that only the last condition is false and all the rest are true. (We read from the right to the left)

So my real question is:

If I use decimal output numbers like 1,2,4,8,16 e.t.c - in a large numbers of conditions - can we transform this cumulative output number to a binary one (like Microsoft calculator or Excel does) and in the case of positive response, how do it (via FML language)?

Thanks

Dionusos

Jose  
#4 Posted : Sunday, February 4, 2007 5:55:34 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Dionusos, you are basically asking if after you've turned binary conditions into decimal numbers, they could then be turned back into binary conditions. I would suggest that you save yourself a lot of unnecessary work, and deal exclusively with binary conditions: Example: cond1:=C>Ref(C,-1); cond2:=V>50000; cond3:=RSI(14)>50; cond1 AND cond2 AND cond3 jose '-)
hayseed  
#5 Posted : Sunday, February 4, 2007 8:39:48 AM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey dion.... the short answer to your question is yes... my concern mentioned above, adding things up, which just requires dividing them back out can be best overcome by the use of a commentary in a expert advisor....

now that i clearly see your goal another point arises.... jose and roy have pointed out to us about meta's rounding of digits .... so there would be a limitation on the length of the binary number...

rather than use one's we could code to use binary numbers .... once meta plotted your binary string you can run your mouse over the plot and clearly see the , 1's and 0's, which would clearly show each true or false.....

again, remember jose/roy's rounding and don't overlook the power of a commentary.....

the code below, using your progressive binary numbering scheme, only works if you have C:\Metastock Data\nasdaq 100\csco and Fml("BM NASDAQ McClellan Oscillator") ..... holler back if unclear......h

-------------------------------------------

a:=If(C>Ref(C,-1), .1, 0);
aa:=If(V>50000, .01, 0);
aaa:=If(RSI(14)>50, .001, 0);
aaaa:=If(Stoch(5,3)>Ref(Stoch(5,3),-1), .0001, 0);
aaaaa:=If(MACD()>Ref(MACD(),-1), .00001, 0);
aaaaaa:=If(Fml("BM NASDAQ McClellan Oscillator")>Ref(Fml("BM NASDAQ McClellan Oscillator"),-1), .000001, 0);
aaaaaaa:=If(Security("C:\Metastock Data\nasdaq 100\csco", C) > Ref(Security("C:\Metastock Data\nasdaq 100\csco", C),-3),.000001,0);

a+aa+aaa+aaaa+aaaaa+aaaaaa+aaaaaaa

--------------------------------------------

dionusos1  
#6 Posted : Sunday, February 4, 2007 11:13:39 AM(UTC)
dionusos1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/6/2007(UTC)
Posts: 6

Hi Jose and hayseed, thanks for yours replay.

If I create an indicator with yours code:

cond1:=C>Ref(C,-1);
cond2:=V>50000;
cond3:=RSI(14)>50;
cond1 AND cond2 AND cond3

I have an indicator with only two Binary signals. 0 and 1.

If 1 = all 3 conditions are True, if 0= all 3 conditions are false. Nothing else if one or two conditions are true or false.

If I create an indicator with my code

Cond1:=If(C>Ref(C,-1), 1, 0);

Cond2:=If(V>50000, 2, 0);

Cond3:=If(RSI(14)>50, 4, 0);

cond1 +cond2 +cond3

I have got an indicator with seven decimal numbers between 0 and 7

If 7= all 3 conditions are true and if 0= all 3 conditions are false

BUT

if 6 = (Cond2 and Cond3)= true and Cond1=false

(The decimal number 6 corresponds to the binary number 1,1,0 =>which means cond2+cond3=true and cond1=false )

If 5 = (Cond1 and Cond3)=true and Cond2=false

If 4 = (cond3=true) and Cond1 and cCond2 = false

and so on….

What does it mean in practice?

If I would like to examine the entry (or exit) signal for 10 (or 100) systems I could know exactly when and which of them give a signal for entry (or exit) only with this indicator

Example

{Long Entry}

Syst1:=(if LE=1,1,0);

Syst2:=(if LE=1,2,0);

Syst3:=(if LE=1,4,0);

Syst4:=(if LE=1,8,0);

Syst5:=(if LE=1,16,0):

……

Syst10:=(if LE=1,512,0);

Syst1+Syst2+Syst3+Syst4+……Syst10

If all the systems procure a signal for entry, the total decimal number will be 1023 => the binary number for this decimal number (1023) is 1,1,1,1,1,1,1,1,1,1. So all conditions are true.

And what about for one other number like 897. This decimal numbers correspond to 1,1,1,0,0,0,0,0,0,1 binary number= so syst1, sys2, syst3, syst10, =true (give an entry signal) and 0 (false) for the rest.

So my question is :

Is there a way to transform the decimal input number to binary output sequence numbers (no to binary signal) via FML?

(Decimal number=0, 1, 2, 3, 4, 5, 6, 7, 8, 9) (Binary number=1, 0)

Thanks

Dionusos

dionusos1  
#7 Posted : Sunday, February 4, 2007 11:14:17 AM(UTC)
dionusos1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/6/2007(UTC)
Posts: 6

Hi Jose and hayseed, thanks for yours replay.

If I create an indicator with yours code:

cond1:=C>Ref(C,-1);
cond2:=V>50000;
cond3:=RSI(14)>50;
cond1 AND cond2 AND cond3

I have an indicator with only two Binary signals. 0 and 1.

If 1 = all 3 conditions are True, if 0= all 3 conditions are false. Nothing else if one or two conditions are true or false.

If I create an indicator with my code

Cond1:=If(C>Ref(C,-1), 1, 0);

Cond2:=If(V>50000, 2, 0);

Cond3:=If(RSI(14)>50, 4, 0);

cond1 +cond2 +cond3

I have got an indicator with seven decimal numbers between 0 and 7

If 7= all 3 conditions are true and if 0= all 3 conditions are false

BUT

if 6 = (Cond2 and Cond3)= true and Cond1=false

(The decimal number 6 corresponds to the binary number 1,1,0 =>which means cond2+cond3=true and cond1=false )

If 5 = (Cond1 and Cond3)=true and Cond2=false

If 4 = (cond3=true) and Cond1 and cCond2 = false

and so on….

What does it mean in practice?

If I would like to examine the entry (or exit) signal for 10 (or 100) systems I could know exactly when and which of them give a signal for entry (or exit) only with this indicator

Example

{Long Entry}

Syst1:=(if LE=1,1,0);

Syst2:=(if LE=1,2,0);

Syst3:=(if LE=1,4,0);

Syst4:=(if LE=1,8,0);

Syst5:=(if LE=1,16,0):

……

Syst10:=(if LE=1,512,0);

Syst1+Syst2+Syst3+Syst4+……Syst10

If all the systems procure a signal for entry, the total decimal number will be 1023 => the binary number for this decimal number (1023) is 1,1,1,1,1,1,1,1,1,1. So all conditions are true.

And what about for one other number like 897. This decimal numbers correspond to 1,1,1,0,0,0,0,0,0,1 binary number= so syst1, sys2, syst3, syst10, =true (give an entry signal) and 0 (false) for the rest.

So my question is :

Is there a way to transform the decimal input number to binary output sequence numbers (no to binary signal) via FML?

(Decimal number=0, 1, 2, 3, 4, 5, 6, 7, 8, 9) (Binary number=1, 0)

Thanks

Dionusos

Jose  
#8 Posted : Sunday, February 4, 2007 12:14:50 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Dionusos, if you wish to differentiate between different signal plots, you could try something like this: cond1:=C>Ref(C,-1); cond2:=V>50000; cond3:=RSI(14)>50; cond1;cond2*2;cond3*3 {...etc} jose '-)
dionusos1  
#9 Posted : Monday, February 5, 2007 8:03:43 PM(UTC)
dionusos1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/6/2007(UTC)
Posts: 6

Hi Jose

Your last code could be nice like an indicator but what about for an exploration?

I would like to run an exploration in order to investigate a big number of conditions using only ONE formula.

I also want the output number to give me 2 kind of information. Quantitative = how many of these conditions are true or false and qualitative = which of them are true or false.

In my opinion there is only one way to arrive at this result. I must use the sequence of the decimal system numbers 1, 2,4,8,16,32 …etc

First step: Create the code for investigate 4 conditions

{4 Conditions)

Cond1:=If(C>Ref(C,-1), 1, 0);

Cond2:=If(V>50000, 2, 0);

Cond3:=If(RSI(14)>50, 4, 0);

Cond4:=If(AroonUp(14)>50, 8, 0);

Allcnds:=cond1 + cond2 + cond3 + cond4;

Second step: Create the code for make the correspondence between the decimal system numbers and the binary system numbers (In this example only for 4 conditions - parameters)

{Convert decimal to binary}

bin:=If(Allcnds=1,1,

If(Allcnds=2,10,

If(Allcnds=3,11,

If(Allcnds=4,100,

If(Allcnds=5,101,

If(Allcnds=6,110,

If(Allcnds=7,111,

If(Allcnds=8,1000,

If(Allcnds=9,1001,

If(Allcnds=10,1010,

If(Allcnds=11,1011,

If(Allcnds=12,1100,

If(Allcnds=13,1101,

If(Allcnds=14,1110,

If(Allcnds=15,1111,

0)))))))))))))));

Third step: Create the code for return back to decimal system numbers

{Convert binary to decimal}

dec:=If(bin=1,0001,

If(bin=10,0002,

If(bin=11,0012,

If(bin=100,0003,

If(bin=101,0013,

If(bin=110,0023,

If(bin=111,1230,

If(bin=1000,0004,

If(bin=1001,0014,

If(bin=1010,0024,

If(bin=1011,0124,

If(bin=1100,0034,

If(bin=1101,0134,

If(bin=1110,0234,

If(bin=1111,1234,

0)))))))))))))));

dec

Run the exploration

If one security obtains the decimal value 1234, all conditions are true.

If one security obtains the decimal value 123, cond1, cond2 and cond3 are true and cond4 is false.

If one security obtains the decimal value 12 cond1 and cond2 are true and cond3 and cond4 are false….etc

Dionusos

Jose  
#10 Posted : Monday, February 5, 2007 8:26:30 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Dionusos, I would skip the decimal -> binary "conversion" steps this way: {4 Conditions} Cond1:=C>Ref(C,-1); Cond2:=(V>50000)*10; Cond3:=(RSI(14)>50)*100; Cond4:=(AroonUp(14)>50)*1000; AllConds:=Cond1+Cond2+Cond3+Cond4; AllConds Result: 1111 = all conds true 0111 = conds 123 true 1011 = conds 124 true 1001 = conds 14 true etc... jose '-)
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.