in Search

Expert - buy/sell to show only once for condition

Last post 06-11-2009, 16:00 by jer99. 2 replies.
Sort Posts: Previous Next
  •  06-10-2009, 17:49 29894

    Expert - buy/sell to show only once for condition

    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.

  •  06-10-2009, 19:47 29895 in reply to 29894

    Re: Expert - buy/sell to show only once for condition

    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 Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-11-2009, 16:00 29900 in reply to 29895

    Re: Expert - buy/sell to show only once for condition

    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.

    ;-)

     

View as RSS news feed in XML