fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. machTucker
    3. Posts
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 11
    • Best 2
    • Controversial 0
    • Groups 0

    Posts made by machTucker

    • RE: Problem generating Oninit code?

      It's annoying. When accessing deals and writing to csv I only seem to get DEAL_ENTRY_OUT deals when using the custom mql block in onTrade(). When I manually put the code into ontradeTransaction() it works fine. This is after making sure I use HistorySelect first.

      FYI that code was generated by chatGPT.

      posted in Questions & Answers
      M
      machTucker
    • RE: Problem generating Oninit code?

      Thanks @jstap . I have managed to get it to work by manually adding some code to the OnTradeTransaction() event function after fxdreema has generated its code. Is there a way of specifying the OnTradeTransaction function from fxdreema?/ I thought maybe it would be possible using a custom function but I'm not familiar with that part of fxdreema yet.

      posted in Questions & Answers
      M
      machTucker
    • RE: Problem generating Oninit code?

      Thanks for the help everyone. I'm using the custom mql code block as I can code a little. I'm trying to output all deals (ENTRY_IN and ENTRY_OUT) and eventually I will be logging the indicator values at time of entry and exit.

      At the moment it is only logging DEAL_ENTRY_OUT deals. Can anyone see what I'm doing wrong? The code is a follows and under On trade.

      //===========================================
      // FXDreema On Trade Custom Block Logger
      //===========================================
      
      // static variable to track last logged deal
      static ulong last_logged_deal = 0;
      
      // get total number of deals
      int total_deals = HistoryDealsTotal();
      if(total_deals <= 0)
          return;
      
      // get the latest deal ticket
      ulong deal_ticket = HistoryDealGetTicket(total_deals - 1);
      if(deal_ticket == 0)
          return;
      
      // avoid logging the same deal twice
      if(deal_ticket == last_logged_deal)
          return;
      
      last_logged_deal = deal_ticket;
      
      // select the deal
      if(!HistoryDealSelect(deal_ticket))
          return;
      
      //-------------------------------------------
      // get deal info
      //-------------------------------------------
      ulong deal_order      = HistoryDealGetInteger(deal_ticket, DEAL_ORDER);
      ulong position_id     = HistoryDealGetInteger(deal_ticket, DEAL_POSITION_ID);
      string symbol         = HistoryDealGetString(deal_ticket, DEAL_SYMBOL);
      long deal_type_i      = HistoryDealGetInteger(deal_ticket, DEAL_TYPE);
      long deal_entry_i     = HistoryDealGetInteger(deal_ticket, DEAL_ENTRY);
      long deal_reason_i    = HistoryDealGetInteger(deal_ticket, DEAL_REASON);
      datetime deal_time    = (datetime)HistoryDealGetInteger(deal_ticket, DEAL_TIME);
      double volume         = HistoryDealGetDouble(deal_ticket, DEAL_VOLUME);
      double profit         = HistoryDealGetDouble(deal_ticket, DEAL_PROFIT);
      double price          = HistoryDealGetDouble(deal_ticket, DEAL_PRICE);
      double swap           = HistoryDealGetDouble(deal_ticket, DEAL_SWAP);
      double commission     = HistoryDealGetDouble(deal_ticket, DEAL_COMMISSION);
      long magic            = HistoryDealGetInteger(deal_ticket, DEAL_MAGIC);
      string comment        = HistoryDealGetString(deal_ticket, DEAL_COMMENT);
      
      //-------------------------------------------
      // get current market prices
      //-------------------------------------------
      double bid = SymbolInfoDouble(symbol, SYMBOL_BID);
      double ask = SymbolInfoDouble(symbol, SYMBOL_ASK);
      double spread = ask - bid;
      
      //-------------------------------------------
      // convert enums to readable strings
      //-------------------------------------------
      string deal_type = "";
      switch(deal_type_i)
      {
         case DEAL_TYPE_BUY: deal_type="DEAL_TYPE_BUY"; break;
         case DEAL_TYPE_SELL: deal_type="DEAL_TYPE_SELL"; break;
         case DEAL_TYPE_BALANCE: deal_type="DEAL_TYPE_BALANCE"; break;
         case DEAL_TYPE_CREDIT: deal_type="DEAL_TYPE_CREDIT"; break;
         default: deal_type="OTHER";
      }
      
      string deal_entry = "";
      switch(deal_entry_i)
      {
         case DEAL_ENTRY_IN: deal_entry="DEAL_ENTRY_IN"; break;
         case DEAL_ENTRY_OUT: deal_entry="DEAL_ENTRY_OUT"; break;
         case DEAL_ENTRY_INOUT: deal_entry="DEAL_ENTRY_INOUT"; break;
         default: deal_entry="OTHER";
      }
      
      string deal_reason = "";
      switch(deal_reason_i)
      {
         case DEAL_REASON_EXPERT: deal_reason="DEAL_REASON_EXPERT"; break;
         case DEAL_REASON_SL: deal_reason="DEAL_REASON_SL"; break;
         case DEAL_REASON_TP: deal_reason="DEAL_REASON_TP"; break;
         case DEAL_REASON_SO: deal_reason="DEAL_REASON_SO"; break;
         case DEAL_REASON_CLIENT: deal_reason="DEAL_REASON_CLIENT"; break;
         default: deal_reason=IntegerToString(deal_reason_i);
      }
      
      //-------------------------------------------
      // write to CSV
      //-------------------------------------------
      int file = FileOpen("MyStrategy.csv",
                          FILE_READ|FILE_WRITE|FILE_CSV|FILE_SHARE_WRITE|FILE_COMMON, ",");
      
      if(file != INVALID_HANDLE)
      {
          FileSeek(file,0,SEEK_END);
      
          FileWrite(file,
              deal_ticket,
              deal_order,
              position_id,
              symbol,
              deal_type,
              deal_entry,
              deal_reason,
              TimeToString(deal_time,TIME_DATE|TIME_SECONDS),
              DoubleToString(volume,2),
              DoubleToString(profit,2),
              DoubleToString(price,_Digits),
              DoubleToString(swap,2),
              DoubleToString(commission,2),
              magic,
              comment,
              DoubleToString(bid,_Digits),
              DoubleToString(ask,_Digits),
              DoubleToString(spread,_Digits)
          );
      
          FileClose(file);
      }
      
      posted in Questions & Answers
      M
      machTucker
    • RE: Problem generating Oninit code?

      Great, I’ll look into it. Thanks.

      posted in Questions & Answers
      M
      machTucker
    • RE: Problem generating Oninit code?

      @jstap Ahhh....got it! Thanks jstap

      I'm considering buying your book. Do you have a pdf copy that I'd be able to read on a ipad?

      posted in Questions & Answers
      M
      machTucker
    • Problem generating Oninit code?

      Hi everyone,

      I'm trying to create a csv file in OnInit() and not having much luck. It's a basic as it gets atm but it doesn't seem to be generating the code in the mq5 file. Any ideas?

      https://fxdreema.com/shared/VLVmredxd

      posted in Questions & Answers
      M
      machTucker
    • RE: Logic (true-false) block not behaving as I expected

      I've managed to sort it. Used a condition block instead of a flags block. Im guessing the flags block just checks flags that are set by a set block.

      posted in Questions & Answers
      M
      machTucker
    • RE: Logic (true-false) block not behaving as I expected

      @jstap Hmm, OK. I set up a constant called use_regime as an input variable. I intended for the user to be able to set either true or false before running the EA. I'm guessing I haven't done that correctly? I selected the constant in the logic block, what am I doing wrong?

      posted in Questions & Answers
      M
      machTucker
    • Logic (true-false) block not behaving as I expected

      Hi everyone,

      https://fxdreema.com/shared/P2p5QJbD

      Newbie to fxdreema here. Getting to grips with the blocks etc and trying to build and replicate some existing strategies I have coded myself.

      I was trying to implement a custom indicator and in doing so used a logic block. Very simple test....if true then use custom indicator and buy, if false sell.

      When I run it it sells all the time regardless of how the flag is set. What am I doing wrong?

      E

      posted in Questions & Answers
      M
      machTucker
    • RE: New here.. how can I post a link to fxdreemer files for help?

      Fantastic, thankyou

      posted in General Discussions
      M
      machTucker
    • New here.. how can I post a link to fxdreemer files for help?

      Hi everyone,

      I'm very new here and just evaluating. I've previously coded EAs myself and just checking fxdreemer out. I have to say it seems excellent so far. I'm having a few problems with a logical (true/false) block.

      I've created a test case for you to have a look at, how can I post that on here?

      E

      posted in General Discussions
      M
      machTucker
    • 1 / 1