Discussions
»
Special Interest Groups
»
Basic Coding Techniques
»
Expert - buy/sell to show only once for condition
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2006(UTC) Posts: 33
|
I would like to have my EA show a buy arrow the first time a condition is met until a second condition appears. For example:
Condition 1 (Buy)
mov(c,12,s) > mov(c,24,s) and rsi(14) > 60
Condition 2 (sell)
mov(c,24,s) > mov(c,12,s) and rsi(14) < 60
I would like to see one arrow the first time a buy or sell is done and then when the opposite condition exists, the other arrow. But only once.
I tried placing the above logic into an EA and got multiple Buys/Sells.
I understand why that happened - I'm used to writting code in a linear fashion like:
if condition1 and not flag1
then
flag1 = true
place arrow
end if
but the environment is different and am having a tough time with this type of logic.
|
|
|
|
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)
|
Search the forum for "latches" or "latching", also have a look in the forum.dll for the latch function, or read Roy Larsen's excellent guide to writing latches which can be found in the files section of the forum.
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2006(UTC) Posts: 33
|
thanks wabbitt.
I forgot about that - I did a search and found I asked the same question a while back. I took a hiatus from the forum..and I forgot a lot.
;-)
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Special Interest Groups
»
Basic Coding Techniques
»
Expert - buy/sell to show only once for condition
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.