[英]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.