Forum

HELP: Calculate risk per trade based on fixed amount & risk percent of account balance

Hello traders. My code down here doesn't place trades when I select risk type as fixed amount or as a risk percent of the account balance . It only places trades when fixed lot size is selected in the user inputs. The CalculateLotSize function should calculate lot sizes based on stop loss distance

HELP: This function should return the highest price between the last two closed trades.

This function should return the highest price between the last two closed trades, i.e. from the open of the second last trade to the close of the very last trade. I don't know where I am going wrong. Help me out. //Returns highest price between the last two closed trades double Highest_Price(){

HELP NEEDED: Help with this function. The function should return true if the last two consecutive trades closed with a loss or with 0 profit.

//Returns true if last two closed trades ended up in a loss or 0(breakeven) bool LastTwoTradesLost(){ double profitLossArray[]; int totalCount = 0 ; HistorySelect ( 0 , TimeCurrent ()); if ( HistoryDealsTotal ()> 0 ){ for ( int i= HistoryDealsTotal ()- 1 ; i>= 0 ; i--){ ulong

Getting how long the last closed position took

Hello coders. I am try to get how long the last closed position took in milliseconds, from entry to exit. The code below doesn't seem to produce what I want. Please advise. I am beginner in MQL5, so bear with me. struct DEALTIME{ long dealentryIn; long dealentryOut; }; DEALTIME time; int OnInit