need advice from a trawl pro that controls two positions independently of each other, how can it be implemented?
The trawl needs to distinguish positions in any case, so we can assign different magics to orders and set two trawls with different magics.
Or should we embed the trawl code into the EA? In that case, we should still assign different magic numbers to the orders and duplicate the trail function on two magic symbols. IMHO.
In any case, a trawl needs to distinguish between positions, so it is possible to assign different magics to orders and set two trawls with different magics.
How would that look in the code?
is there a separate trawl for each position?
What if there are 6-8 positions?
Is it really impossible to simplify?
the trawl is in the EA
How would it look in the code? Is it possible to write a new magik for each position?
is there a separate trawl for each position?
What if there are 6-8 positions?
Could it not be simpler?
If there are a lot of positions, it's difficult to have a separate trawl for each one, I agree. If there are two positions at a time, it's fine in my opinion.
Maybe it can be simpler, but what should be the difference in trawl of different orders?
how would it look in the code? would a new magik be written for each position?
Is there a separate trawl for each position?
And what if there are 6-8 positions?
is it really impossible to simplify?
the trawl is in the EA
Disable trawl in EA and use the built-in trawl, there is a separate trawl for each position.
not funny
//--------------------------------------------------------------- 1 -- // Функция модификации StopLoss всех ордеров указанного типа // Глобальные переменные: // Mas_Ord_New Массив ордеров последний известный // int TralingStop Значение TralingStop(количество пунктов) //--------------------------------------------------------------- 2 -- int Tral_Stop(int Tip) { int Ticket; // Номер ордера double Price, // Цена открытия рыночного ордера TS, // TralingStop (относит.знач.цены) SL, // Значение StopLoss ордера TP; // Значение TakeProfit ордера bool Modify; // Признак необходимости модифи. //--------------------------------------------------------------- 3 -- for(int i=1;i<=Mas_Ord_New[0][0];i++) // Цикл по всем ордерам { // Ищем ордера задан. типа if (Mas_Ord_New[i][6]!=Tip) // Если это не наш тип.. continue; //.. то переступим ордер Modify=false; // Пока не назначен к модифи Price =Mas_Ord_New[i][1]; // Цена открытия ордера SL =Mas_Ord_New[i][2]; // Значение StopLoss ордера TP =Mas_Ord_New[i][3]; // Значение TakeProft ордера Ticket=Mas_Ord_New[i][4]; // Номер ордера if (TralingStop<Level_new) // Если меньше допустимого.. TralingStop=Level_new; // .. то допустимый TS=TralingStop*Point; // То же в относит.знач.цены //--------------------------------------------------------- 4 -- switch(Tip) // Переход на тип ордера { case 0 : // Ордер Buy if (NormalizeDouble(SL,Digits)<// Если ниже желаемого.. NormalizeDouble(Bid-TS,Digits)) { // ..то модифицируем его: SL=Bid-TS; // Новый его StopLoss Modify=true; // Назначен к модифи. } break; // Выход из switch case 1 : // Ордер Sell if (NormalizeDouble(SL,Digits)>// Если выше желаемого.. NormalizeDouble(Ask+TS,Digits)|| NormalizeDouble(SL,Digits)==0)//.. или нулевой(!) { // ..то модифицируем его SL=Ask+TS; // Новый его StopLoss Modify=true; // Назначен к модифи. } } // Конец switch if (Modify==false) // Если его не надо модифи.. continue; // ..то идём по циклу дальше bool Ans=OrderModify(Ticket,Price,SL,TP,0);//Модифицируем его! //--------------------------------------------------------- 5 -- if (Ans==false) // Не получилось :( { // Поинтересуемся ошибками: if(Errors(GetLastError())==false)// Если ошибка непреодолимая return; // .. то уходим. i--; // Понижение счётчика } } return; // Выход из пользов. функции } //--------------------------------------------------------------- 6 --trawl code
Well I can only suggest that each order should be assigned a new magik in turn, and that a separate type function should be made for each order:
//--------------------------------------------------------------- 1 -- // Функция модификации StopLoss всех ордеров указанного типа // Глобальные переменные: // Mas_Ord_New Массив ордеров последний известный // int TralingStop_1 Значение TralingStop(количество пунктов) //--------------------------------------------------------------- 2 -- int Tral_Stop(int Tip) { int Ticket; // Номер ордера double Price, // Цена открытия рыночного ордера TS, // TralingStop (относит.знач.цены) SL, // Значение StopLoss ордера TP; // Значение TakeProfit ордера bool Modify; // Признак необходимости модифи. //--------------------------------------------------------------- 3 -- if(OrderMagicNumber() == magic_1){ for(int i=1;i<=Mas_Ord_New[0][0];i++) // Цикл по всем ордерам { // Ищем ордера задан. типа if (Mas_Ord_New[i][6]!=Tip) // Если это не наш тип.. continue; //.. то переступим ордер Modify=false; // Пока не назначен к модифи Price =Mas_Ord_New[i][1]; // Цена открытия ордера SL =Mas_Ord_New[i][2]; // Значение StopLoss ордера TP =Mas_Ord_New[i][3]; // Значение TakeProft ордера Ticket=Mas_Ord_New[i][4]; // Номер ордера if (TralingStop<Level_new) // Если меньше допустимого.. TralingStop=Level_new; // .. то допустимый TS=TralingStop*Point; // То же в относит.знач.цены //--------------------------------------------------------- 4 -- switch(Tip) // Переход на тип ордера { case 0 : // Ордер Buy if (NormalizeDouble(SL,Digits)<// Если ниже желаемого.. NormalizeDouble(Bid-TS,Digits)) { // ..то модифицируем его: SL=Bid-TS; // Новый его StopLoss Modify=true; // Назначен к модифи. } break; // Выход из switch case 1 : // Ордер Sell if (NormalizeDouble(SL,Digits)>// Если выше желаемого.. NormalizeDouble(Ask+TS,Digits)|| NormalizeDouble(SL,Digits)==0)//.. или нулевой(!) { // ..то модифицируем его SL=Ask+TS; // Новый его StopLoss Modify=true; // Назначен к модифи. } } // Конец switch if (Modify==false) // Если его не надо модифи.. continue; // ..то идём по циклу дальше bool Ans=OrderModify(Ticket,Price,SL,TP,0);//Модифицируем его! //--------------------------------------------------------- 5 -- if (Ans==false) // Не получилось :( { // Поинтересуемся ошибками: if(Errors(GetLastError())==false)// Если ошибка непреодолимая return; // .. то уходим. i--; // Понижение счётчика } } return; // Выход из пользов. функции } } //--------------------------------------------------------------- 6 --
not funny
Cheap and cheerful.
If each position has its own trawl, the value of trawl variable should be different for each position. Therefore, for each trawl there is a variable, how many positions at most will you have?
Cheap and cheap.
If each position has its own trawl, then the value of trawl variable should be different for each position. Therefore, for each trawl there is a variable, how many positions at most will you have?
max 8 positions
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
set the trawl, works fine for one position
but if there is more than one position, for example two Sell positions
it closes both of them at the same time
i need a trawl to work for each position separately
when trading manually it is possible, i.e. one position has a Sell StopLoss
the other Sell position has a different StopLoss
Google did not help