- My EA will use 3 strategies and each of these 3 strategies can open more than 1 limit order/position/market order which is why I need multiple order management related code that will enable the code to maintain list of orders/positions seperately for each of the 3 strategies - perhaps by using an array of orders or some other more optimum way. - These strategies together or individually may end up opening more than 1 order so I will need a limit on total number of positions opened(the limit will not check number of pending orders only open positions) as well as Margin awareness as sometimes order cannot be placed if enough margin is not available. - Also my EA and strategy requires complex risk management options which is why I have specified risk management related requirements here. - The EA should have option to use different ways to take profit - by using fixed TP, trailing stop loss , and by closing partial profit peprcentage . Inputs of this EA would include (and will allow the logic to be controlled via these configurations) : - using absolute TP mode or not - if true it will only use a fixed tp - TPPipsforTPMode - this is the tp that will be used if above mode is enabled - Enable flexibility to switch between Absolute TP and trailing profit based on condition (value - true/false) - this requires absolute tp mode to be true - using trailing profit only mode - using partial profit mode - partial profit percentages (key value pair of percentage with tp pips like 60:20, 80:30,100:40 - here 60% of position is closed after 20 pips , 80% is closed after 30 pips, rest is closed after 40 pips is hit) - requires using the above partial profit mode to be true - max number of orders allowed to be opened by this EA - risk percentage per order - calculateRiskonBalance: - if true will calculate lot size based on risk% of balance, if false will use equity instead - numberofConsecutivelossbeforeriskAdjustedMode - False by default: - numberofConsecutiveLossBeforeRiskAdjusted - 3 by default - Basically this will affect the way lot size is calculated . If this mode is true then lets say original capital is 1000, then we will keep on using 1000 amount to calculate the lot size (based on risk %) until we have 3 (value mentioned in this input parameter) consecutiev losses. After 3 consecutive losses the next trade will use the resulting balance after the losses to calculate the new lot sizes (using risk %) until next 3 losses occur. However if profit occurs and balance increases the capital thats used to calculate lot size will be the current balance/equity. - defaultSL - default stop loss to be used for all orders/positions - LimitOrderExpiry - i should be able to specify this in input parameter - showstatsonScreen - true by default - will show the winrate/average RR ratio/ last trade RR ratio / number of trades taken on that day on the Symbol screen when EA is run. - show EA config on screen - will show the EA settings (either distributed left and right to prevent overlapping on the price candles or with the setting to change alignment at topleft/topright/bottoleft/bottom right of screen) - timerange parameter I need code section which includes (The below is the requirement and is suggestive. More optimum ways to implement the code can be used. I need something like this but it should cater to other requirements that have been mentioned such as max number of positions open etc): on start of every new candle : if (strategy1condition == True){ Check if current time is within the time range filter or not call function to place a new order (lots calculated according to risk)(buy/sell/market order/limit order) and store identifier of this order/position/position identifier in an array named strategy1array } if (strategy2condition == True){ call function to place a new order (lots calculated according to risk) (buy/sell/market order/limit order) and store identifier of this order/position/position identifier in an array named strategy2array } if (strategy2condition == True){ call function to place a new order (lots calculated according to risk) (buy/sell/market order/limit order) and store identifier of this order/position/position identifier in an array named strategy3array } on every tick : Go through the order/position identifier arrays for each strategies in a loop to check status of every position that has been opened in the strategy array (its possible that the previously mentioned strategy conditions opened a limit order and it has not yet opened a position yet so we will ignore checking their status as SL management only needs to be done for open positions not pending orders) This status check loop will be used to (all below options need to be implemented): - (check condition) - update the SL (Break even) - (check condition) update the SL (for trailing SL mode) - (check condition) take partial profit mode - Check state of position to perform certain actions (see below for more info) - I need a way to maintain state of each of the open position - either through some variable that stores the state or some other mechanism (something that does not slow down the code/EA) The state would store information like - 'Waiting for 2 different MA to crossover" Which would be used by my algorithm to (after that condition has happened) possibly update SL/or to switch from absolute TP to trailing TP mode (in which case TP would have to be increased/removed so that its not hit easily). The code for identification and maintainance of the order/position using an identifier needs to be robust enough such that it can handle situations like swaps are charged or the server refreshes, partial filling of orders, orders being filled after a delay and any other wierd situations that can occur while trading.