How to I put in leverage on the EA

 

Hi,

I've created an EA which works perfectly in the testing mode. The issue with running in in real mode is because I don't have enough money to trade as the test mode, so I need to use leverage, which my account permits. Is there a way to code the leverage in so that I can execute the trades using the EA? The lots I am using for buying and selling work just the same amount if I'm not using the EA, but with the EA it doesn't work because it says I don't have enough money.

Thanks,

 

No, you do not use "leverage" in an EA. What you do is check the margin requirements and adjust the volume accordingly.

But before you do that you should be adjusting for the risk correctly first.

Forum on trading, automated trading systems and testing trading strategies

How to calculate take profit from currency

Fernando Carreiro, 2022.09.05 17:00

These are all the same equation written in different ways ...

[Volume]      = [Money Value] * [Tick Size] / ( [Tick Value] * [Stop Size] )
[Stop Size]   = [Money Value] * [Tick Size] / ( [Tick Value] * [Volume]    )
[Money Value] = [Volume]      * [Stop Size] * [Tick Value]   / [Tick Size]

[Volume] in lots
[Stop Size] in quote price change
[Money Value] in account currency
 
Fernando Carreiro #:

No, you do not use "leverage" in an EA. What you do is check the margin requirements and adjust the volume accordingly.

But before you do that you should be adjusting for the risk correctly first.

I found out the error. I put lots wrong. I put 0.1 and I meant to put 0.01 instead. That fixed it. Thanks

Reason: