Forum

How do I save the order/open price for all open orders in an array?

Hello, How would I save the order open price for all open orders and save it into an array which updates every time I add another order? My code is below. double OrderOpenPriceBuyArray[ 10 ]; datetime LastTimeBuy; //LastBuyOrderTime ( int j = 0 ; j < OrdersTotal (); j++) { if ( OrderSelect (j

How do I compound lot size based on order?

Hello, My code below does not seem to work. I am trying to increase my lot size every time a new order is placed and incrementally increase it as more order are placed. input double Lotsize = 0.1 ; input double Increment = 0.1 ; double FinalLots = 0; for ( int i = 0 ; i < OrdersTotal (); i++) {

How do I save the latest order price and loop?

Hello, I am trying to get the EA to create orders when the price moves x pips away from open order price and then use that price level to make the next trade based off that. I am trying to update 'LastPriceBuy' with the price from the newest order and only if price moves x pips away from that new

How to detect a trade made by the user?

Hello, MQL4 does not seem to have an inbuilt function where a trade made by the user is detected. I am not even sure how I would go around defining it? Has anyone got an idea how to approach this problem? Thank you

How to solve zero divide error in my code?

Hello guys, I am running into a zero divide error because my formula is based on the percentage change from the lowest/highest the last x bars and due to the nature of this it gives me a zero divide error. I am not sure how to solve this, if anybody could provide some insight it would be much

How to save Ask price and set lot size based on that?

Hello, I am trying to create an ea which sets its lot sizing based on the distance it's away or near to the price where the criteria was first met. However, in the strategy tester , it does not seem to take any trades at all. My code is below. int TicketBuy; int Magix = 89424 ; double SignalPrice;

How does Close[0] index its values?

I am creating an EA where it checks the Close[0] to either buy/close/sell. My question is because bar 0 is not fully formed yet, is the Close[0] considered as the ask/bid? Or is it only considered a Close once the bar has completed. I need to know because if it is only considered a close once the

How to have multiple separate criteria to close the same Ticket? Invalid Ticket for OrderClose Function.

Hello, I am trying to close my trades based on 2 separate types of criteria, 1. Regardless of what the profit is, close the trade after 1020 seconds. 2. If my import value changes from -1 to 1 or vice versa, close it regardless of any other variables. So far, my code works fine with 1 criteria

Error code 5008 Invalid Handle (handle index is out of handle table) When reading CSV

My code below is running into error 5008 and from my understanding it's because I'm not closing the csv file after reading it? However I have closed it but don't seem to figure out why this is popping up. My files are in the MQL4/Files folder so my file path is correct. Can someone please tell me

How to read a single cell from a CSV file?

Hello, there is not a lot of documentation on this issue, I need to get just one value from a cell from a csv file. My code is below and it doesn't seem to work. I've checked every thread and I do not seem to understand how reading specific columns/rows/cells works in MQL4. Any clarity on this case