How can I set stop loss above/below the price action structure? - page 2

Vladimir Karputov
Moderator
301933
Ruben Ortega # :

The problem is that i dont know how to call to the high (nº1 view image) and put the stop there

Please draw a picture for BUY and for SELL. Specify Stop Loss and Take Profit.

Ruben Ortega
37
Ruben Ortega  
Vladimir Karputov #:

Please draw a picture for BUY and for SELL. Specify Stop Loss and Take Profit.

I had drawn it (its only for sells) thank you - VIEW IMAGE

William Roeder
27511
William Roeder  
Ruben Ortega #: I want to set the stop loss above the structure (view image)

“Until you can state what you mean by “structure” in concrete terms (MA, fractal, highest, etc.) it can not be coded.” Explain how you get (per your picture) № 1 and not № 5.

Ruben Ortega
37
Ruben Ortega  
William Roeder #:

“Until you can state what you mean by “structure” in concrete terms (MA, fractal, highest, etc.) it can not be coded.” Explain how you get (per your picture) № 1 and not № 5.

//+------------------------------------------------------------------+
//|                                                    Robot_50%.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

input double SL = 5;
input double TP = 5;
input int magic = 1;

input double HoraInicial=8;//0-23
input double HoraFinal=17 ;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   bool trade = true;

   for (int i=0;i<OrdersTotal();i++) {


      int orden_seleccionada = OrderSelect (1,SELECT_BY_POS,MODE_TRADES);
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==magic) {
         trade= false;
            break;
}
}
      if (trade==true ) {

         if (venta()==true && FiltroCompra()==true /*&& OperacionesAbiertas()==0*/) {

            int venta = OrderSend(NULL,OP_SELL,1,Bid,10,SL,TP,"Keltner inverso",magic,0, clrRed);
  }
  }
  
  }
  
//+------------------------------------------------------------------+

     bool venta(){
     
     
     double cuatro = 0;
     double tres = 0;
     double dos = 0;
     double uno = 0;
     double x = 0;
    
     for(int i=2;i<250;i++){
     
      double ind = iCustom(NULL,0,"ZigZag.ex4",20,5,1,0,i); //Here i start to make the stucture i want
      
      if(ind!=0){
      
         if(cuatro==0 && tres==0 && dos==0 && uno==0 && x==0){
            cuatro = ind;
         }
         if(cuatro!=0 && tres==0 && dos==0 && uno==0 && x==0 && ind!=cuatro){
            tres = ind;
         }
         if(cuatro!=0 && tres!=0 && dos==0 && uno==0 && x==0 && ind!=cuatro && ind!=tres){
            dos = ind;
         }
         if(cuatro!=0 && tres!=0 && dos!=0 && uno==0 && x==0 && ind!=cuatro && ind!=tres && ind!=dos){
            uno = ind;
            
         }
         if(cuatro!=0 && tres!=0 && dos!=0 && uno!=0 && x==0 && ind!=cuatro && ind!=tres && ind!=dos && ind!=uno){
            x = ind;
            break;
         }
      }
     } 
     
     if( uno > dos && tres < uno && tres > cuatro && tres > dos && x < uno && cuatro < dos && High[1]>tres+50*Point && Close[2]<tres){
      return true;
     }else{
     return false;
     
     }
     
     }
  
 
   double stoploss=Bid+100*Point; 
   double takeprofit=NormalizeDouble(Ask-200*Point,Digits);
 
      
     
     
     
     
     
   bool FiltroCompra(){
  
      if(Hour()>=HoraInicial && Hour()<=HoraFinal){
      
         return true;
      }
      else
      return false;}
      
      
      
      
    int OperacionesAbiertas(){
  
      int liOrders = 0;
      for (int i = 0; i < OrdersTotal(); i++){
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false){
          continue;
        }
        if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic){
          continue;
        }
        liOrders++;
      }
      return(liOrders);
}

Here is the code and the image, i want to modify the stop loss above nº1 in the image. Thanks

Files: