Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
daiwa wrote: 2)
What would be more efficent way to express this formula as CCI is only one change in expert advisor ?
(CCI cross between 3 and 21 days and RSI cross between 3 and 5 days)
Cross(Stoch(5,3),20) AND Cross(CCI(3),-100) AND Cross(RSI(3),30) OR Cross(CCI(5),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR Cross(CCI(8),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR Cross(CCI(13),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR Cross(CCI(21),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR Cross(CCI(34),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR Cross(Stoch(5,3),20) AND Cross(CCI(3),-100) AND Cross(RSI(5),30) OR Cross(CCI(5),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR Cross(CCI(8),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR Cross(CCI(13),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR Cross(CCI(21),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30)
Daiwa, To start, you should try to make the objective of the code as clear as possible. We know the operator precedence is AND before OR so we can see what is going on more easily if you re-write the code, with judicious use of brackets too: Code:Cross(CCI(3),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR
Cross(CCI(5),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR
Cross(CCI(8),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR
Cross(CCI(13),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR
Cross(CCI(21),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR
Cross(CCI(34),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(3),30) OR
Cross(CCI(3),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR
Cross(CCI(5),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR
Cross(CCI(8),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR
Cross(CCI(13),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30) OR
Cross(CCI(21),-100) AND Cross(Stoch(5,3),20) AND Cross(RSI(5),30)
Now we can see that each line is evaluated, and only one line has to be true for the entire function to be true. We can also see the Cross(Stoch(5,3),20) is common to each line and is a condition that must be true if the function is true, so extract this. Code:Cross(Stoch(5,3),20) AND
(
Cross(CCI(3),-100) AND Cross(RSI(3),30) OR
Cross(CCI(5),-100) AND Cross(RSI(3),30) OR
Cross(CCI(8),-100) AND Cross(RSI(3),30) OR
Cross(CCI(13),-100) AND Cross(RSI(3),30) OR
Cross(CCI(21),-100) AND Cross(RSI(3),30) OR
Cross(CCI(34),-100) AND Cross(RSI(3),30) OR
Cross(CCI(3),-100) AND Cross(RSI(5),30) OR
Cross(CCI(5),-100) AND Cross(RSI(5),30) OR
Cross(CCI(8),-100) AND Cross(RSI(5),30) OR
Cross(CCI(13),-100) AND Cross(RSI(5),30) OR
Cross(CCI(21),-100) AND Cross(RSI(5),30)
)
we can now see a little more clearly? The code now appears to be attempting to find the condition when there is a CCI cross AND the cross of either of two RSIs of their levels. This is true for all CCI lengths, except we notice there is a CCI(34) appearing in the middle of the code but not at the end. Is this an error or intentional? Lets pretend it is intentional and deal with the code as is. Lets combine the RSI crosses against their respective CCI crosses: Code:Cross(Stoch(5,3),20) AND
(
Cross(CCI(3),-100) AND (Cross(RSI(3),30) OR Cross(RSI(5),30)) OR
Cross(CCI(5),-100) AND (Cross(RSI(3),30) OR Cross(RSI(5),30)) OR
Cross(CCI(8),-100) AND (Cross(RSI(3),30) OR Cross(RSI(5),30)) OR
Cross(CCI(13),-100) AND (Cross(RSI(3),30) OR Cross(RSI(5),30)) OR
Cross(CCI(21),-100) AND (Cross(RSI(3),30) OR Cross(RSI(5),30)) OR
Cross(CCI(34),-100) AND Cross(RSI(3),30)
)
which can be further simplified by isolating the (Cross(RSI(3),30) OR Cross(RSI(5),30)) expression: Code:Cross(Stoch(5,3),20) AND
(
(Cross(RSI(3),30) OR Cross(RSI(5),30)) AND
(
Cross(CCI(3),-100) OR
Cross(CCI(5),-100) OR
Cross(CCI(8),-100) OR
Cross(CCI(13),-100) OR
Cross(CCI(21),-100)
)
OR
(
Cross(CCI(34),-100) AND Cross(RSI(3),30)
)
)
If the final expression was an error: Code:Cross(Stoch(5,3),20) AND
(
(Cross(RSI(3),30) OR Cross(RSI(5),30)) AND
(
Cross(CCI(3),-100) OR
Cross(CCI(5),-100) OR
Cross(CCI(8),-100) OR
Cross(CCI(13),-100) OR
Cross(CCI(21),-100) OR
Cross(CCI(34),-100)
)
)
Hope this helps. wabbit [:D]
|