What's new

Closing Trades if floating balace is in X% In negative

Hello,

Logic i am looking for :

If floating Balance is less than 1% in negative of account balance => Close the trade (OR) if floating balance is less than $100 in negative => Close the trade


Code :


Code:
extern int negative_equity_percentage = 1;
extern int negative_equity_balance = 50;
double equity = AccountEquity();
double Account_balance = AccountBalance();
double floatingBalance = equity - Account_balance;

void CheckAndCloseTrade()

{
        double NewspercentageThreshold = 0.01 * negative_equity_percentage * Account_balance;
        if ((floatingBalance < NewspercentageThreshold) || (floatingBalance < -negative_equity_balance)) {
            closetrade();

        }
}


void closetrade() {
//Closing Trade Logic

}

int start()
{
CheckAndCloseTrade(;
return(0);
}



Error : Balance, Equity and Floating balance do not change in Real time. Instead it takes the initial value when installing the EA and the values remains same.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

Users Who Are Viewing This Thread (Total: 1, Members: 0, Guests: 1)

Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock    No Thanks