Results 1 to 5 of 5
 0 Attachment(s)    

Thread: Long Only / Short Only /Long and Short

  1. #1

    Default Long Only / Short Only /Long and Short

    How does an EA made with the default MQL4 blank EA wizard actually screen long out or short only conditions?? I see no actual visible code for this on any EA...
    Thanks BillR

  2. #2


    There are two ways to achieve this.

    Firstly, attach any EA to a chart and in the Common tab of the EA properties box you can select Only Long, Only Short or Long & Short.

    The alternative is to add a couple of external bools in Global Scope such as:

    extern bool TradeLong=true;
    extern bool TradeShort=true;

    Then, as an extra entry condition before sending your orders:

    if(TradeLong && //your other conditions ..............
    ) {GoLong;}

    if(TradeShort && //your other conditions ..............
    ) {GoShort;}

  3. #3


    Thanks for the reply Jezzer Yes, I know of both these ways and I was curious as to how the "Common Tab" actually "does" what it does. I have an EA that does "Long only"....and "Long and Short" just fine, but fails to trade "Short only" when "Short Only" is selected...and don't know where to look to fix it. I was hoping to fix it there instead of with the extern bool but right now extern bool seems to be the only way to stop long...
    Last edited by BillR; 04-27-2009 at 22:36.

  4. #4


    It's probably no consolation, Bill, but it's not the first time I've heard of MT4 doing seemingly the wrong thing. Sometimes a restart can clear any conflict.

    You have a similar option to trade both ways in the Strategy Tester. Have you tried that to see if it does the same thing?

  5. #5


    Jezzer, Yes...same thing in the tester, but the bool true/false works..

Similar Threads

  1. EA that changes long / short on MA cross
    By sebastianhh in forum MQL programming
    Replies: 1
    Last Post: 10-27-2010, 21:04
  2. Open Long and Short Order simultaneously
    By fairylord in forum Scripts and other tools
    Replies: 9
    Last Post: 03-09-2010, 12:25
  3. Colored Stochastic + Cross Alert to signal Long\Short
    By MechXTrader in forum Indicators
    Replies: 0
    Last Post: 06-16-2009, 12:07
  4. Long Island Tea 2
    By NICK35 in forum Expert advisors backtesting
    Replies: 11
    Last Post: 03-09-2009, 17:26

Tags for this Thread

color, mql, mql4, mt4, stop, strategy, time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts