fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Ipod
    3. Topics
    I
    • Profile
    • Following 2
    • Followers 2
    • Topics 18
    • Posts 121
    • Best 7
    • Controversial 0
    • Groups 0

    Topics created by Ipod

    • I

      MT5 Very simple news filter
      Tutorials by Users • • Ipod

      37
      0
      Votes
      37
      Posts
      9027
      Views

      T

      any example for mt4? Please!

    • I

      Variables + Constants inside Custom MQL code block?
      Questions & Answers • • Ipod

      3
      0
      Votes
      3
      Posts
      240
      Views

      I

      Ahhhhhhh

      It does work! It turns out I had not spelled something correctly and it was trying to check a custom enum rather than the output of the enum. Now I can remove about 50 unrequired blocks in my ea, yikes.

      Thanks 🙂

    • I

      risk based volume (OrderCalcProfit) ?
      Questions & Answers • • Ipod

      12
      0
      Votes
      12
      Posts
      825
      Views

      I

      I created a script, so if you are using Equity, Balance, or Free Margin risk based lot size as per the below picture and block. So if you export your code to mq5, then load my script it will automatically replace the necessary code to give accurate volume size on pairs like gold that never used to calculate correctly.

      You still need tp specify your Risk in %, Max lot and Stop loss either in distance or price level but other than that it should work.

      ddaa0d30-bdb1-4f1a-ad13-49f70af868e3-image.png

      827226b0-d430-46b1-b198-6510e50de034-image.png

      Also a warning I do run these project options, 0.01 = 0.1 is an extra addition.

      88883779-5c7b-4f12-a985-ac3ad8f44e3d-image.png

      Below is a Python script, so make a text file and put this code into it and then change the file etension to .py when you run the code it will request a file to open, select desired mql5 and it will change the code internally automatically. Python is required on your pc for script to work.

      import tkinter as tk from tkinter import filedialog def replace_and_add_code(file_path): try: # Open the file with UTF-16 Little Endian encoding with open(file_path, 'r', encoding='utf-16-le') as file: content = file.read() # Replace the size calculations old_code = [ 'else if (mode=="equityRisk") {size=((value/100)*AccountEquity())/(sl*TickValue*PipValue(symbol));}', 'else if (mode=="balanceRisk"){size=((value/100)*AccountBalance())/(sl*TickValue*PipValue(symbol));}', 'else if (mode=="freemarginRisk") {size=((value/100)*AccountFreeMargin())/(sl*TickValue*PipValue(symbol));}' ] new_code = [ 'else if (mode=="equityRisk") {size = VolLongPoints(symbol,(value/100)*AccountEquity(),10*sl);}', 'else if (mode=="balanceRisk"){size = VolLongPoints(symbol,(value/100)*AccountBalance(),10*sl);}', 'else if (mode=="freemarginRisk") {size = VolLongPoints(symbol,(value/100)*AccountFreeMargin(),10*sl);}' ] for j in range(len(old_code)): content = content.replace(old_code[j], new_code[j]) # Define the new function to add function_to_add = ''' double VolLongPoints(string pSymbol, double pMoney, double pSlp) { double Volstep = SymbolInfoDouble(pSymbol,SYMBOL_VOLUME_STEP); double Volmax = SymbolInfoDouble(pSymbol,SYMBOL_VOLUME_MAX); double Volmin = SymbolInfoDouble(pSymbol,SYMBOL_VOLUME_MIN); pMoney = floor(pMoney); double tickSize = SymbolInfoDouble(pSymbol,SYMBOL_TRADE_TICK_SIZE); double freeMargin = AccountInfoDouble(ACCOUNT_MARGIN_FREE); double point = SymbolInfoDouble(pSymbol,SYMBOL_POINT); double Price = SymbolInfoDouble(pSymbol,SYMBOL_ASK); Price = round(Price/tickSize)*tickSize; double slPrice = Price - pSlp * point; slPrice = round(slPrice/tickSize)*tickSize; double dbProfit = 0; double riskLots = 0; double OrderLots = 0; double reqMarg = 0; if(OrderCalcProfit(ORDER_TYPE_BUY, pSymbol, Volmax, Price, slPrice, dbProfit) == true) { OrderLots = fmin(fmax(round(pMoney * Volmax / (MathAbs(dbProfit) * Volstep)) * Volstep, Volmin), Volmax); } else if(!OrderCalcProfit(ORDER_TYPE_BUY, pSymbol, Volmax, Price, slPrice, dbProfit)) { Print("Volume calc Failed: ", GetLastError()); } //------ if(OrderCalcMargin(ORDER_TYPE_BUY,pSymbol,OrderLots,Price,reqMarg) == true) { double R = MathAbs(floor(freeMargin) / round(reqMarg)); // Calculate the ratio double OrderLotsAdjusted = 0; if(R < 1) // Check if the free margin is less than the required margin { OrderLotsAdjusted = OrderLots * R; // Reduce the order volume proportionally Print("Not enough money to execute trades with : ",DoubleToString(OrderLots)," Volume adjusted based on free margin to required margin ratio to : ",DoubleToString(OrderLotsAdjusted)); OrderLots = OrderLotsAdjusted; } } if(OrderLots < Volmin) { OrderLots = Volmin; } riskLots = floor(OrderLots/Volstep)*Volstep; return riskLots; } ''' # Insert the new function above 'double AccountBalance()' insert_index = content.find('double AccountBalance()') if insert_index != -1: content = content[:insert_index] + function_to_add + content[insert_index:] # Write the changes back to the file with open(file_path, 'w', encoding='utf-16-le') as file: file.write(content) print("File updated successfully.") except Exception as e: print(f"An error occurred: {e}") def main(): root = tk.Tk() root.title("File Selector") root.geometry('300x150') def select_file(): file_path = filedialog.askopenfilename( title="Select the .mq5 file", filetypes=[("MQL5 files", "*.mq5")] ) if file_path: replace_and_add_code(file_path) label.config(text="File Processed") else: label.config(text="No file selected.") label = tk.Label(root, text="Please select your .mq5 file") label.pack(pady=10) btn = tk.Button(root, text="Select File", command=select_file) btn.pack(pady=10) root.mainloop() if __name__ == "__main__": main()
    • I

      Add constants in one block
      Questions & Answers • • Ipod

      3
      0
      Votes
      3
      Posts
      102
      Views

      I

      @l-andorrà my first post was confusing hence the simpler one here, I do believe it's possible just I have not figured it out yet.

      Thanks anyway.

    • I

      Condition check before allowing entry
      Questions & Answers • • Ipod

      9
      0
      Votes
      9
      Posts
      551
      Views

      l'andorrà

      Congrats! 😉

    • I

      Random external variable
      Questions & Answers • • Ipod

      2
      0
      Votes
      2
      Posts
      121
      Views

      I

      Nevermind I just found it in a comment box with a tick 🐶

    • I

      Calc to the power of? e.g 1.5^3 for expanding grids
      Questions & Answers • • Ipod

      6
      0
      Votes
      6
      Posts
      340
      Views

      I

      NVM think i found an example, thank you for that sktsec

      https://fxdreema.com/forum/topic/5983/square-root

    • I

      Count highest drawdown over time (Chart / pair only)
      Questions & Answers • • Ipod

      1
      0
      Votes
      1
      Posts
      189
      Views

      No one has replied

    • I

      [Tutorial] Daily Drawdown + Reset
      Tutorials by Users • • Ipod

      7
      3
      Votes
      7
      Posts
      1743
      Views

      l'andorrà

      The file is available for MT5.

    • I

      Simple block order ID question
      Questions & Answers • • Ipod

      5
      0
      Votes
      5
      Posts
      305
      Views

      A

      @Ipod 👍

    • I

      Spread variable trouble
      Questions & Answers • • Ipod

      6
      0
      Votes
      6
      Posts
      357
      Views

      P

      @Ipod @l-andorrà The spread value may differ between brokerage houses and it may not be the right decision to use this data in backtests. For the value you would use for each position though:12.png

    • I

      modify stop loss in percent calculation?
      Questions & Answers • • Ipod

      16
      0
      Votes
      16
      Posts
      999
      Views

      I

      @l-andorrà @salek i actually have custom code for fxdreema to fix this problem, which requires running a script at the exported mql5 which then replaces the incorrect code within the ea. You then compile within mt5 directly.

      I made a post a long time ago about the correction using custom code but I could share what I use here if you wanted.

      Stop loss in percent, equity percent etc then work correctly on all forex pairs, index’s and also commodities like gold.

    • I

      Cannot get Hedging basics to work, Master coder required :)
      Questions & Answers • • Ipod

      7
      0
      Votes
      7
      Posts
      1183
      Views

      I

      No problem I will stick to my variable martingale for now 🙂 building a good base and then adding conditions, news filters and maybe some other stuff 😄

      Thank you for the assistance though

    • I

      Martingale via add volume ADX used for grid distance issue
      Questions & Answers • • Ipod

      2
      0
      Votes
      2
      Posts
      900
      Views

      fxDreema

      I see some problem here - string vs boolean - not a good idea to compare them like that:
      0_1552928477571_31bec418-7a48-490a-91ad-51223e722002-image.png
      Better select Numeric or even Boolean, but don't use Text.

      So, are you asking how to make the ADX value negative? Try that:
      0_1552928683252_fa0f37dc-e699-4c8c-9e84-aef85ddf771b-image.png

    • I

      Trading statistics on chart accuracy %
      Questions & Answers • • Ipod

      2
      0
      Votes
      2
      Posts
      984
      Views

      I

      NVM I have figured it out, I was using flags instead of condition true or false

    • I

      My first fxdreema scalping EA, I wish to add martingale / grid
      Questions & Answers • • Ipod

      1
      0
      Votes
      1
      Posts
      1396
      Views

      No one has replied

    • I

      Creating a drop down menu?
      General Discussions • • Ipod

      3
      0
      Votes
      3
      Posts
      3104
      Views

      I

      Okay thanks for the code and advice, I think I will just stick to creating seperate EA's and not complicate things exponentially 😄

    • 1 / 1