Here's an EA. it opens a position on a fractal up/down. How do I make the stop 5 pips higher (if BUY) and 5 pips lower (if SELL) from the top of the fractal?
P_up0=iCustom(0,0,"Ценовой канал", Chperiod,0,0);
P_down0=iCustom(0,0,"Ценовой канал", Chperiod,1,0);
P_up1=iCustom(0,0,"Ценовой канал", Chperiod,0,1);
P_down1=iCustom(0,0,"Ценовой канал", Chperiod,1,1);
Up=iCustom(0,0,"olyakish_fractals_02(для Skonti)",15,150,"Процент для отсеивания по объему",110,1,3);
Down=iCustom(0,0,"olyakish_fractals_02(для Skonti)",15,150,"Процент для отсеивания по объему",110,3,3);//задали все данные
total=OrdersTotal();if( total<1){// Проверка свободной маржиif(AccountFreeMargin()<(1000* Lots)){Print("We have no money. Free Margin = ",AccountFreeMargin());return(0);}// Условие открытие позиции BUYif( Up> Down){
Lots= GetSizeLot();
ticket=OrderSend(Symbol(),OP_BUY, Lots,Ask,3,0,0,"",16384,0,Green);if( ticket>0){if(OrderSelect( ticket, SELECT_BY_TICKET, MODE_TRADES))Print("BUY order opened : ",OrderOpenPrice());}elsePrint("Error opening BUY order : ",GetLastError());return(0);}// Условие открытие позиции SELLif( Up< Down){
Lots= GetSizeLot();
ticket=OrderSend(Symbol(),OP_SELL, Lots,Bid,3,0,0,"",16384,0,Red);if( ticket>0){if(OrderSelect( ticket, SELECT_BY_TICKET, MODE_TRADES))Print("SELL order opened : ",OrderOpenPrice());}elsePrint("Error opening SELL order : ",GetLastError());return(0);}return(0);}for( cnt=0; cnt< total; cnt++){OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol()){if(OrderType()==OP_BUY)// длинная позиция открыта{// условие закрытие длинной позицииif( P_down1> P_down0|| Up< Down){OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);return(0);}if( TrailingStop>0){if(Bid-OrderOpenPrice()>Point* TrailingStop){if(OrderStopLoss()<Bid-Point* TrailingStop &&OrderStopLoss()!=OrderOpenPrice()+ X*Point){OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+ X*Point,OrderTakeProfit(),0,Green);return(0);}}}}else{// условие закрытия короткой позицииif( P_up1< P_up0|| Up> Down){OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);return(0);}if( TrailingStop>0){if((OrderOpenPrice()-Ask)>(Point* TrailingStop)){if(NormalizeDouble(OrderStopLoss(),Digits)!=NormalizeDouble(OrderOpenPrice()- X*Point,Digits)){OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()- X*Point,OrderTakeProfit(),0,Red);return(0);}}}}}}return(0);}
All questions are resolved by experiment - write a script, run it, - we see the following differences of the standard iFractals() 1. the indicator by the fractal index is exactly equal to High/Low 2. non-existing value of the fractal ==0
it is unclear what it means to call, in the global variables of the program -Remember the time of a bar fractal to open a position. Using the time of the bar, we know the bar number through iBars() -remember the fractal price remember the fractal price - remember up / down and then what to do once again?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
oops :-)
thank you!
Hello connoisseurs!
Here's an EA. it opens a position on a fractal up/down. How do I make the stop 5 pips higher (if BUY) and 5 pips lower (if SELL) from the top of the fractal?
I have used the Price Channel here.
иI'm having trouble identifying the L or H of the fractal at which the position was opened!
roughly like this!!!?
so multiply by the price of the lowermost digit
This is where I made a mistake. Thanks.
On how to set the top of the fractal on which the position was opened????
- we see the following differences of the standard iFractals()
1. the indicator by the fractal index is exactly equal to High/Low
2. non-existing value of the fractal ==0
P.S. look back from the position by this cycle, at the moment of position opening, remember
in the global variables of the program
-Remember the time of a bar fractal to open a position. Using the time of the bar, we know the bar number through iBars()
-remember the fractal price
remember the fractal price - remember up / down
and then what to do once again?
above all blocks
write the nearest fractal when opening a buy order
enter another condition for the buy order