How can I set stop loss above the price action structure?

 

Hi, I´m developing an EA that sells and i dont know how to set my stop loss above the structure (view image). Please help me

//+------------------------------------------------------------------+
//|                                                    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()
  {
//---

   if ( OperacionesAbiertas()==0 && venta()==true && FiltroCompra()==true)
   {
         OrderSend(NULL,OP_BUY, 1.0,Ask,1,SL,Close [1]+(iATR (NULL, 0, 23, 1) *TP), "COMPRA RobotEjemplo1",Magic);
      }
  }
//+------------------------------------------------------------------+

   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);
      
      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          /*Close[1]>tres && Close[2]<tres /*|| Close[3]<tres || Close[4]<tres/*uno-x > 250*Point*/){
      return true;
     }else{
     return false;
     
     }
     }
Files:
 
Ruben Ortega: Hi, I´m developing an EA that sells and i dont know how to set my stop loss above the structure (view image). Please help me

You are double posting. You already have a thread open for the same question, and with users answers:

Forum on trading, automated trading systems and testing trading strategies

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

Ruben Ortega, 2022.05.11 15:09

Hi, I´m making my own EA and I need to set my stop loss above the stucture for sells (view image) but I don´t know how to do  it.


Reason: