Описание проблемы в мт4
Я выводил на графике в советнике 670 билда ( режиме тестера), через глобальную переменную для индикатора Функцию AccountMargin() (стоимость закупки позиций)
Последовательность действий
вот программа проверки: (не важно сколько лотов, для примера взят минимальный лот)
if(flag==0) { if(OrdersTotal()<=30) { OrderL(0.01); } // открываем лонг 0,01 /// OrderS(0.01); if(OrdersTotal()>30) {OrderS(0.01);} // открываем шорт 0,01 и открываем лонг 0,01 if(OrdersTotal()>80) {CLOSE_ALL(); flag=1;} все закрыть и остановиться! } GlobalVariableSet("Grafik",AccountMargin());
Полученный результат в зависимости от вариантов (см файлы)
В советнике происходит не правильный расчет AccountMargin()
1) лонги + (лонги +шорты)
- сначала растет с увеличением позиции ( правильно!)
- потом стабилизируется при добавлении позиций S - это грубая ошибка, такого не может быть, чтобы закупки не росли при открытии новых лотов
- и при полном закрытии =0
2) лонги(шорты) + шорты ( лонги)
- сначала растет с увеличением позиции
- потом падает при добавлении позиций S - это грубая ошибка, такого не может быть чтобы закупки не росли при открытии лотов
- и при полном закрытии =0
3) сразу лонги+ шорты открываем
- постоянно AccountMargin() =0 ( индикатор график почему-то = 0 не показал! " почему 0 - не показывает? это попутный глюк ?)
- и при полном закрытии =0
4) сначала лонги + затем шорты или сначала шорты+ затем лонги
- сначала растет с увеличением позиции ( правильно!)
- потом стабилизируется при добавлении первой позиций S - это грубая ошибка, такого не может быть, чтобы закупки не росли при открытии новых лотов
- потом падает при добавлении позиций S - бред полный - это грубая ошибка,
- потом =0 при добавлении позиций - такого не может быть никогда
- потом опять растет с увеличением позиции ( правильно!)
- и при полном закрытии =0
Вот открываем лонги , - все нормально - закупка растет
потом открываем шорты и у Вас появляются позиции с знаком противоположным - минус и вычитаются из из общей суммы, потом AccountMargin() дойдя постепенно до 0 вдруг понимает , что отрицательной закупки не бывает!
опять знак почему-то меняется, хотя продолжаем открывать шорты
если поменять местами шорты и лонги - бред будет таким же
AccountMargin() =0 при OrdersTotal() >0 - то это бред полный
Например, Вы купили 100 разных товаров в магазине (тут OrdersTotal() =100), а в ЧЕКЕ (тут AccountMargin() =0) у вас написано " итого 0 ". Вы рады - магазин тоже!!! Даром вы купили , даром вам продали
Странно все это , бред полный - но факт !!
представьте:
Советник делает первую сделку при" продажи " сначала одних шортов - ( товары отрицательные или обратные ) маржа, возвращается назад продавцу в реальной жизни - т.е. AccountMargin() <0 должен быть меньше нуля.
и тогда остаток AccountFreeMargin()= AccountEquity()-AccountMargin() должен расти AccountMargin() <0 после первой сделки, но такого быть не может - поэтому ДОКАЗАНО, что шорт это товар, который покупают, (хотя условно он продается)
а у разработчиков её забирают, когда продан ШОРТ , маржа растет при увеличении закупки шортов (как у обычного товара лонг (товары положительные или прямые) )
а когда начинаю я лонги покупать, они вместо закупки лонгов, возврат делают по закупке (марже)
вот и ясна вся неразбериха со знаками у разработчиков !!
нельзя ПРОДАЖИ ШОРТОВ считать продажами, а надо считать покупками - это я пытаюсь всем объяснить ! открыл ШОРТ - это значит товар купил, а не "продал". Это условное понимание кредита, но не сути.
Ошибку разработчикам признать нельзя отказаться Запятую я и они ставим в разных местах. Короче нахимичили с формулами они, и продолжают опыты над истиной.
Ожидаемый результат
Если я все время открываю позиции , то обязан AccountMargin() все время увеличиваться, независимо от лонгов или шотов
AccountFreeMargin()= AccountEquity()-AccountMargin() связана уравнением с AccountMargin() и поэтому тоже неправильно считает.
Поэтому из-за этого неправильно маржинкол и стоп аут считается , и все другие параметры напрямую связанные с ошибкой.
К сожалению фирма разработчик отказывается исправлять свои ошибки, они так боятся признать ошибки.... не хотят думать над своими ошибками.
Тем кто понимает, что это грубая ошибка я предлагаю не использовать AccountMargin() . Я написал программу нормального учета маржи:
AccountMargin() меняем на AccountMarginAccountMargin
// привел пример //Внимание !! при частичном закрытие лота нельзя применять, надо модифицировать!! //+------------------------------------------------------------------+ ПРАВИЛЬНАЯ итоговая маржа="закупки открытых" минус "возврат закрытых" AccountMargin()=ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin=AccountEquity()-AccountMargin_AccountMargin; //+------------------------------------------------------------------+ глобально присвоим единожды double AccountMarginAccountMargin=0; AccountFreeMarginAccountFreeMargin=AccountEquity()-AccountMargin_AccountMargin; ZAKUPSUM=0; //закупка VozvratSUM=0; //возврат суммы OrderZAK[]; //запомним стоимость ордера //////////////////////////////////////////////////////////////////////////////////////////////////// Уже в программе при тиках когда вызываем действие над позициями //Открытие Buy if(IsTradeAllowed()==1) TicketBUY=OrderSend(Symbol(),OP_BUY,Lts,NormalizeDouble(Ask,Digits),0,0,0," купил лонг",magic,0,clrBlue); if(TicketBUY>0) // Получилось :) { OrderZAK[magic]=Lts*Ask*Contract_1_LOT/plecho; //запомним стоимость ордера ZAKUPSUM=ZAKUPSUM+OrderZAK[magic]; закупка лонгов AccountMarginAccountMargin=ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin=AccountEquity()-AccountMargin_AccountMargin; magic=magic+1; } //+------------------------------------------------------------------+
// Закрытие Buy Lot=OrderLots(); // полное закрытие позиции if(IsTradeAllowed()==1) AnsBUY=OrderClose(OrderTicket(),Lot,NormalizeDouble(Bid,Digits),0,clrGreen); if(AnsBUY==true) // Получилось :) { VozvratSUM=VozvratSUM+OrderZAK[OrderMagicNumber()]; возврат суммы после продажи лонгов AccountMarginAccountMargin=ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin=AccountEquity()-AccountMargin_AccountMargin; } //+------------------------------------------------------------------+
//Открытие Sel if(IsTradeAllowed()==1) TicketSELL=OrderSend(Symbol(),OP_SELL,Lts,NormalizeDouble(Bid,Digits),0,0,0," продал шорт",magic,0,clrRed); if(TicketSELL>0) // Получилось :) { OrderZAK[magic]=Lts*Bid*Contract_1_LOT/plecho; //запомним стоимость ордера ZAKUPSUM=ZAKUPSUM+OrderZAK[magic]; закупка шортов AccountMarginAccountMargin=ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin=AccountEquity()-AccountMargin_AccountMargin; magic=magic+1; } //+------------------------------------------------------------------+
// Закрытие Sell Lot=OrderLots(); // полное закрытие позиции if(IsTradeAllowed()==1) AnsSELL=OrderClose(OrderTicket(),Lot,NormalizeDouble(Ask,Digits),0,clrDarkOrange); if(AnsSELL==true) // Получилось :) { VozvratSUM=VozvratSUM+OrderZAK[OrderMagicNumber()]; возврат суммы после откупа шортов AccountMarginAccountMargin=ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin=AccountEquity()-AccountMargin_AccountMargin; } //+------------------------------------------------------------------+
по английски
Description of the problem in MT4
I have shown in the chart in the EA 670 build (tester mode) through a global variable for the indicator function AccountMargin () (purchase price products)
Sequence of operations
But check program (no matter how many items for example taken the minimum lot)
if (flag == 0) { if (OrdersTotal () <= 30) {OrderL (0.01); // Open} Long 0,01 /// OrderS (0.01); if (OrdersTotal ()> 30) {OrderS (0.01);} // open shorts and open 0.01 0.01 Long if (OrdersTotal ()> 80) {CLOSE_ALL (); flag = 1;} all close and stop! } GlobalVariableSet ("Grafik", AccountMargin ());
The result obtained, depending on the options (see files)
In the advisor is not calculated properly AccountMargin ()
1) Long + (longs + shorts)
- first increases with the position (right!)
- then stabilized by the addition of positions S - is a gross mistake, this can not be to the purchase did not grow at the opening of the new items
- and fully closed = 0
2) longs (shorts) + shorts (longs)
- first increases with increasing gap
- then decreases with the addition of positions S - is a gross mistake, this can not be to the purchase did not grow at the opening of lots
- and fully closed = 0
3) immediately longs + shorts open
- constantly AccountMargin () = 0 (the indicator chart for some reason = 0 is not shown "why 0 - does not show? passing it a glitch?)
- and fully closed = 0
4) first and then longs + shorts or shorts + first then longs
- first increases with the position (right!)
- then stabilized by the addition of the first position S - is a gross mistake, this can not be to the purchase did not grow at the opening of the new items
- then decreases with the addition of positions S - complete nonsense - it's a blunder,
- = 0 then when adding items - such can never be
- then again increases with the position (that's right!)
- and fully closed = 0
That's called Long - everything is fine - the purchase grows
then open the shorts and you appear to mark the position of the opposite - negative and deducted from the total amount of, then AccountMargin () reaching gradually to 0 realizes that negative purchase does not happen!
Again the sign somehow changed, although we continue to open shorts
if swap shorts and longs - nonsense is the same
Strangely it all complete nonsense - but the fact !!
Expected result
If I keep open position, shall AccountMargin () all the time to grow, regardless of longs or shots
AccountFreeMargin () = AccountEquity () - AccountMargin () associated with the equation AccountMargin () and therefore also wrong to assume.
Therefore, because of this wrong marzhinkol and stop out is considered and all other parameters are directly related to the error.
Unfortunately the developer company refuses to correct their mistakes, they are so afraid to admit mistakes .... do not want to think about your mistakes.
Those who understand that it is a gross mistake, I suggest not to use AccountMargin (). I wrote a program normal margin account:
AccountMargin () change on AccountMarginAccountMargin
// An example // Attention !! with the partial closure of the lot can not be used, it is necessary to modify !! // + ----------------------------------------------- ------------------- CORRECT final margin = "public procurement" minus "return closed" AccountMargin () = ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin = AccountEquity () - AccountMargin_AccountMargin; // + ----------------------------------------------- ------------------- globally assign once double AccountMarginAccountMargin = 0; AccountFreeMarginAccountFreeMargin = AccountEquity () - AccountMargin_AccountMargin; ZAKUPSUM = 0; // Purchase VozvratSUM = 0; // Refund amount OrderZAK []; // remember the order price ////////////////////////////////////////////////// ////////////////////////////////////////////////// Already in the program when ticks When the action over the positions // Open Buy if (IsTradeAllowed () == 1) TicketBUY = OrderSend (Symbol (), OP_BUY, Lts, NormalizeDouble (Ask, Digits), 0, 0, 0, "bought Long", magic, 0, clrBlue); if (TicketBUY> 0) // turned out :) { OrderZAK [magic] = Lts * Ask * Contract_1_LOT / plecho; // remember the order price ZAKUPSUM = ZAKUPSUM + OrderZAK [magic]; purchase longs AccountMarginAccountMargin = ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin = AccountEquity () - AccountMargin_AccountMargin; magic = magic + 1; } // + ----------------------------------------------- -------------------
// Close Buy Lot = OrderLots (); // full closing position if (IsTradeAllowed () == 1) AnsBUY = OrderClose (OrderTicket (), Lot, NormalizeDouble (Bid, Digits), 0, clrGreen); if (AnsBUY == true) // turned out :) { VozvratSUM = VozvratSUM + OrderZAK [OrderMagicNumber ()]; The refund amount after the sale longs AccountMarginAccountMargin = ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin = AccountEquity () - AccountMargin_AccountMargin; } // + ----------------------------------------------- -------------------
// Open Sel if (IsTradeAllowed () == 1) TicketSELL = OrderSend (Symbol (), OP_SELL, Lts, NormalizeDouble (Bid, Digits), 0, 0, 0, "sold short", magic, 0, clrRed); if (TicketSELL> 0) // turned out :) { OrderZAK [magic] = Lts * Bid * Contract_1_LOT / plecho; // remember the order price ZAKUPSUM = ZAKUPSUM + OrderZAK [magic]; purchase shorts AccountMarginAccountMargin = ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin = AccountEquity () - AccountMargin_AccountMargin; magic = magic + 1; } // + ----------------------------------------------- -------------------
// Close Sell Lot = OrderLots (); // full closing position if (IsTradeAllowed () == 1) AnsSELL = OrderClose (OrderTicket (), Lot, NormalizeDouble (Ask, Digits), 0, clrDarkOrange); if (AnsSELL == true) // turned out :) { VozvratSUM = VozvratSUM + OrderZAK [OrderMagicNumber ()]; The refund amount after paying off shorts AccountMarginAccountMargin = ZAKUPSUM-VozvratSUM; AccountFreeMarginAccountFreeMargin = AccountEquity () - AccountMargin_AccountMargin; }
// + ----------------------------------------------- -------------------