[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 665
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Do not count highs and lows from the zero bar but from the first bar, on the zero bar the Bid cannot be less than the Min.
double
Min=Bid, variable declaration
Max=Bid,
____________________________________________________________________________________________
for (i=0;i<=20-1;i++) opening criteria
{if (Low[i]<Min) Min=Low[i]:
if (High[i]>Max) Max=High[i];
}
if (................. &&Ask>Max)
{
Opn_B=true; //open Buy
}
if (................ &&Bid<Min)
{
Opn_S=true; //open Sell
}
___________________________________________________________________________________________
I'm sorry it's so ugly - I had to write it from memory as the code didn't work and I deleted it. But you, as a professional, should be understandable (I hope).
____________________________________________________________________________________________
You flatter me :)) I'm a beginner just like you...
It goes something like this. Didn't check it, just wrote it on the spot...So here is the logic:
1. set the pending order with a magic number, say 101, and reset the flag to convert the order into a position, say ConvOrd=false;
2. check if the position with magic 101 has appeared; if so, set the conversion flag ConvOrd=true;
3. Check ConvOrd for truth and if ConvOrd==true,
we check if the position with magic number 101 exists - and if it is missing
it means it is already closed.
{deselect ConvOrd=false; set a new pending one;}.
I think we can do without flags...
I understand the logic, but I don't know how to implement it in code. I've tried a lot of variants but I haven't got any result. I think I'm a dummy. That's why I wrote here. On p.663 I showed you my code. If you are interested, please tell me how to improve it or at least tell me how to improve it. Thank you.
Try a simpler way, when you put a SellStop order, remember the TakeProfit value and if the Bid falls below that price, put it on Buy.
Try a simpler way, when you place a SellStop order, remember the TakeProfit value and if the Bid falls below that price, put it on Buy.
Thanks for the advice! I have already tried this option but it is not suitable for my strategy.
I don't understand why there are two locking positions at once. The logic is as follows:
When equity reaches a certain percentage of the previous profit, we close all positions... This works properly... Next...
If the equity falls by a certain percentage from its previous value, look for the position with the largest loss, identify who it is... Buy or Sell...
and open a locking position in the opposite direction with double lot. Then we look at their total profit (of the losing and locking position) and as soon as it gets bigger,
Let's say 10 pips, close them...
Logically, the equity should be checked on the next tick and if everything is OK, we continue working... If everything is OK again, we will have to look for the next sucker...
But for some reason it opens two locking positions at once... and Buy and Sell, and if the lot was 0.1, then the first locking opens double the lot = 0.2,
and the second one doubles it again and opens with 0.4 lot ... Respectively, what the hell lot is there, if they're fighting with each other for a place under the Sun ... :(
I'm attaching the code, maybe someone could poke me with their... finger.
Starting from
//------------- Включение вывода убыточных позиций в ноль, если эквити упало на N процентов -----------------------
...there's a joint somewhere...
PAGE NUMBER "666" :-)