简体   繁体   English

如何在Metatrader4中基于帐户货币计算手数

[英]How to calculate lot based on account currency in Metatrader4

I am a little bit new in this language, but I have the basics. 我在这种语言上有点新,但是我有基本知识。

What I want: open a position with stop loss and take profit. 我想要的是:开立止损仓位并获利。

I want to place an order with 100 euro, and I want to set the stop loss to 10 euros, and set the take profit to 5 euros. 我想下一个100欧元的订单,我想将止损设置为10欧元,将止盈设置为5欧元。 But as I see the OrderSend method requires lots for placing the order, and levels for stop loss and take profit. 但是,正如我所看到的,OrderSend方法需要大量下单,止损和获利水平。

And my problem is: how to calculate these values based on the euro amounts I want to set? 我的问题是:如何根据我要设置的欧元金额计算这些值?

I searched for some lot-pip-etc calculation on the web, but after all what I tried did not work. 我在网上搜索了很多手法等计算方法,但毕竟我尝试的方法不起作用。 This is how I wanted to calculate: 这就是我要计算的方式:

double AmountToTradeInEuro = 100;
double AmountToTakeInEuro = 5;
double AmountToMaxLossInEuro = 10;
double Lots = AmountToTradeInEuro / MarketInfo(Symbol(), MODE_TICKVALUE);
double StopLossLevel = AmountToTakeInEuro / MarketInfo(Symbol(), MODE_TICKVALUE);
double TakeProfitLevel = AmountToMaxLossInEuro / MarketInfo(Symbol(), MODE_TICKVALUE);
OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, StopLossLevel, TakeProfitLevel);

Basically I would like to know how to calculate the Lot for 100 euro and how to calculate the Levels for stoploss and takeprofit. 基本上,我想知道如何计算100欧元的手数,以及如何计算止损和止盈水平。

And are the stoploss and takeprofit levels also lots? 止损和止盈水平也很多吗? Or are they different units? 还是他们是不同的单位?

Welcome to MQL4! 欢迎使用MQL4! First question is about the account currency - if it is USD (or something else not EUR) - you have to make such convertion. 第一个问题是关于帐户货币-如果是美元(或其他不是欧元的货币),则必须进行这种转换。 Ok, let me describe what to do with the EUR balance. 好的,让我描述一下如何处理欧元余额。 You can compute lot size based on the stoploss - in such a case you can get tick value using MarketInfo(_Symbol,MODE_TICKVALUE) . 您可以基于止损计算手数-在这种情况下,您可以使用MarketInfo(_Symbol,MODE_TICKVALUE)获得报价值。 But you must know the price level where to exit (stoploss), whether it is 1 pips or 100 pips. 但是您必须知道退出的价格水平(止损),无论是1点还是100点。 Let us think that is 100 ticks (which is equal to 10 pips of 5-digit broker). 让我们认为这是100个报价(等于10点的5位数经纪人)。 Then, your lot size is 那你的手数是
double lot = AmountToMaxLoss / (MarketInfor(_Symbol, MODE_TICKVALUE) * stoploss) , then you have to normalize the result: double lot = AmountToMaxLoss / (MarketInfor(_Symbol, MODE_TICKVALUE) * stoploss) ,则必须将结果标准化:

double lot_step=MarketInfo(_Symbol, MODE_LOTSTEP); double result = lot_step * NormalizeDouble(lot / lot_step, 0); then check that result > MarketInfo(_Symbol, MODE_MINLOT) . 然后检查result > MarketInfo(_Symbol, MODE_MINLOT) About takeprofit - it might be a strange approach to wait for your takeprofit target in the currency instead of the price level but if you need - the way is same. 关于获利–等待货币(而不是价格水平)中的获利目标可能是一种奇怪的方法,但是,如果需要的话-方法是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 MetaTrader4 终端中获取当前毫秒数? - How to get current milliseconds in MetaTrader4 Terminal? 如何使用 MetaTrader4 错误代码刷新进行正确的错误处理? - How to use a MetaTrader4 Error Code Refresh for proper error handling? 如何从vb.net实时从MetaTrader4终端(MT4)读取蜡烛数据 - How to read candle data from a MetaTrader4 Terminal ( MT4 ) from vb.net in realtime 如何从 MQL4 EA 流程(MetaTrader4 终端)运行 Python 脚本? - How to run a python script from an MQL4 EA-process ( MetaTrader4 Terminal )? MetaTrader4终端,策略测试器:在交易发生之前如何从[结果窗口]跳至[图表]? - MetaTrader4 Terminal, Strategy Tester: how to jump from a [ Results Window ] to the [ Graph ] BEFORE a Trade Happens? 将互联网时间数据导入metatrader4 - Import internet time data into metatrader4 如何以帐户货币计算mt5中的掉期(转存) - How to calculate the swap (rollover) in mt5 in term of account currency 在MQL4 MetaTrader4中根据Symbol()定义数组[专家顾问] - Defining an array, depending on Symbol(), in MQL4 MetaTrader4 [Expert Advisor] Metatrader4/MQL4 代码:依赖类的“错误参数计数” - Metatrader4/MQL4 code: “wrong parameters count” with dependent classes 从metatrader4向python中的电报机器人发送消息 - send message from metatrader4 to telegram bot in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM