fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. greatscott
    G
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 9
    • Best 0
    • Controversial 0
    • Groups 0

    greatscott

    @greatscott

    0
    Reputation
    188
    Profile views
    9
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    greatscott Unfollow Follow

    Latest posts made by greatscott

    • RE: Send Email - but ignore pending orders

      __Try the Send e-mail block again :)[/quote:mkdv4up5]

      I think it's still waiting for a tick before "Trade created" or "Trade closed" gets triggered, so it doesn't get to the SendEmail block.

      posted in Questions & Answers
      G
      greatscott
    • RE: Send Email - but ignore pending orders

      __Maybe you are right 🙂 I added extra checks in the purple blocks, it should work fine now[/quote:8dwo361u]

      YES YES YES!!! Pending orders are ignored now, yahooooo. 🙂 Thank you! The only item left on my wishlist is to make it run every 1 second instead of waiting for a tick. I would create a new share link but looks like I'm out of shares on my basic account. I scrapped the pink blocks!

      __nice work 🙂
      I am not tried this, but you can, this way working in OnTimer:
      https://fxdreema.com/shared/xdSGKe0ad[/quote:8dwo361u]

      I might give this a try when I have a clear head tomorrow - what you did here definitely makes sense. Thank you very much for the idea!

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Send Email - but ignore pending orders

      __What do you mean by pending trade? Trade closed should pass if running trade is closed, not if pending order is deleted.[/quote:3gkxmgo2]

      That's what I thought initially, but using "Trade created" and "Trade closed" was still causing emails to be sent when pending orders were created or deleted. I've spent the last day trying to figure out how to make it NOT execute on pending orders but couldn't figure it out.

      I'll redo this and get rid of the pink blocks and just use separate Trade created and Trade closed blocks for buys and sells. Oops!

      __I will not make those times to be strings. Time is only string when printed, for the eyes of the person, but in the code it should be integer value :)[/quote:3gkxmgo2]

      That was the point - I wanted them in a nice "pretty" format in the email message, which means it needs to be a string, right? So it can be printed like 2016.10.24 05:34 in the email.

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Send Email - but ignore pending orders

      Using "Order created" didn't work either - I still couldn't figure out how to filter out the pending trades.

      But that's OK because I figured out a workaround by modifying the source code.

      Below I'm going to share what I did so anyone else can use this too, but first I want to ask, what is the easiest way to make this EA run every 1 second instead of on every tick?

      I'm currently using the "onTrade" tab. If I move all the blocks to the "onTimer" tab and set my project settings timer to 1 second, nothing worked at all. So it looks like I need to use the onTrade tab, but the blocks only seem to execute whenever there's an active tick on the chart that the EA is attached to. Can I force it to "run" every second in addition to every tick?

      Ok, here's what I did:

      https://fxdreema.com/shared/cb2Kkt6Fb

      And then I modified the MQ4 file. Find the spot where the trade data is calculated and I did this:

      Replace OpenTime code with:

      string ic_eventTrade_e_attrOpenTime()
      {
      	return TimeToString(e_attrOpenTime(), TIME_DATE) + " " + TimeToString(e_attrOpenTime(), TIME_MINUTES);
      }
      

      This makes it a string and includes the date and time in a nice format.

      Do the same thing with CloseTime:

      string ic_eventTrade_e_attrCloseTime()
      {
      	return TimeToString(e_attrCloseTime(), TIME_DATE) + " " + TimeToString(e_attrCloseTime(), TIME_MINUTES);
      }
      

      I wanted the PROFIT for closed trades reported as pips instead of dollars, so I replaced the Profit section with this:

      double ic_eventTrade_e_attrProfit()
      {
         int pipMult = 10000;
         if(StringFind(OrderSymbol(),"JPY",0) != -1) pipMult = 100;
         double orderpipsprofit;
         if(OrderType()==0) {
         orderpipsprofit = (OrderClosePrice() - OrderOpenPrice()) * pipMult;
      	}
      	if(OrderType()==1) {
      	orderpipsprofit = (OrderOpenPrice() - OrderClosePrice()) * pipMult;
      	}
      	return(orderpipsprofit);
      }
      

      And then I wanted to NOT send emails for pending trades, so I went to all four of the SendEmail commands and added the OrderType() if statement:

      if(OrderType()==0 || OrderType()==1) { SendMail(EmailSubject, EmailMessage+"\n"+EmailDataRows); }
      

      So the emails are nicely formatted and look like this:

      __We have closed our BUY trade as follows:

      Symbol: GBPCAD
      Opened At: 1.6352
      Closed At: 1.6347
      Open Time: 2016.10.24 22:07
      Close Time: 2016.10.24 22:15
      Profit: -5 pips
      [/quote:1rw2qf9v]

      I still want to make it run every 1 second but if I can't figure that out, I'll call this "good enough" for now. 🙂

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Send Email - but ignore pending orders

      I am writing an EA that does nothing but send me an email whenever an order is opened or closed.

      I am sooo close. The final step is to make it ignore pending trades.

      https://fxdreema.com/shared/OJR7NCPTd

      Just testing/working on the buy trades for now, I'll do the sell trades next.

      It works fine when I open/close a normal trade.

      It also works when I open a pending order (ie: I do NOT get an email). But when I delete the pending trade, it sends me an email (but it should not).

      I'm comfortable tweaking the MQL code if I know where/what to tweak. I'm also making adjustments in the MQL so it shows me a nice date/time format and closed trade profit in pips (instead of dollars). But I wasn't sure where or how to tell it "not pending orders".

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Trailing Stop Is.... Multiple Levels (minor glitch report)

      I've owned the "EA Wizard" software (for building EAs) for a few years but I can tell you that in just a few days I can see fxdreema is significantly more powerful.

      1. It can manage manual trades (EA Wizard requires a magicnumber to manage a trade)

      2. It can manage all pairs on an account, not just the pair that the EA is attached to

      3. I was able to set up a trailing stop trade management EA with just one rule (block) instead of creating 14 separate rules (7 levels of buys and 7 levels of sells).

      EXTREMELY impressed. Great job!

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Trailing Stop Is.... Multiple Levels (minor glitch report)

      I was able to confirm via backtesting that both your suggestions worked perfectly!

      1. Switching the "Reference Price" to Bid for Buy fixed the spread not being taken into account.

      2. Your MQL syntax was perfect.

      static string tStopMultiple = ""+First_Trail_Start+"/"+First_Trail_Stop+", "+Second_Trail_Start+"/"+Second_Trail_Stop+", "+Third_Trail_Start+"/"+Third_Trail_Stop+", "+Fourth_Trail_Start+"/"+Fourth_Trail_Stop+", "+Fifth_Trail_Start+"/"+Fifth_Trail_Stop+", "+Sixth_Trail_Start+"/"+Sixth_Trail_Stop+", "+Seventh_Trail_Start+"/"+Seventh_Trail_Stop+"";
      

      Last question, I promise. 🙂 In both the "If Trade" and "Trailing Stop" blocks, if I set Market Mode to "any market", the EA will manage all of the trades on the account, not just the symbol that I attached it to. Right? 😮 😎

      https://fxdreema.com/shared/Nvh2k11Jd

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Trailing Stop Is.... Multiple Levels (minor glitch report)

      Thank you very much!

      I almost had that MQL syntax correct, I was missing the + symbols. 🙂

      I'll give all this another try when the market opens.

      -Scott

      posted in Questions & Answers
      G
      greatscott
    • RE: Trailing Stop Is.... Multiple Levels (minor glitch report)

      This is exactly the feature I'm looking for! And it looks functional, except:

      1. It doesn't seem to take the spread into consideration. For example, if the first stoploss move triggers at +10 pips of profit and there's a 2-pip spread, the EA actually moves the stop loss when the trade is +8 pips in profit. I confirmed this on a couple different pairs and multiple trades.

      2. Is there any way to use variables for the levels so they can be adjusted in the inputs?

      Even if it can't be done from within fxdreema, if someone knows the syntax for using a variable name inside a string I can do it manually in the MQL file:

      static string tStopMultiple = "5/1, 10/6, 15/11";
      

      https://fxdreema.com/shared/dFz2GhxGc

      I'm really liking fxdreema; I think I'll build my next full EA project with this tool. 🙂

      -Scott

      Edit: Just confirmed it happens on both buy and sell orders.
      Edit2: DANGIT I just realized there's a separate forum for bug reports. Sorry.

      posted in Questions & Answers
      G
      greatscott