Issue with editing TP

 

Hi! 

I try to create a strategy which works as follows:

- open a Long position at 0:55 am with a very wide TP and SL

- at 1:05 am change TP into the price, at which the current position was initially opened.


Is this possible to create such condition? And if so, could anyone please help me with this? I am sorry if such question has already been asked at the forum, but I can't find such topic anywhere.

I attached the code, which is supposed to open a Long position at 0:55am with wide TP and at 1:05am change TP into 20 pips. How could I edit it, so it would work as I mentioned above?

double TakeProfit;
double LastHigh; 
double LastLow;

int OnInit() 
   {
   Print("Version 1.0");

   return(INIT_SUCCEEDED);
   }
   
int start()
  {  
  LastHigh = iHigh (NULL,0,1);
  LastLow = iLow(NULL,0,1);
  
  Print("Previous High/Low =" ,  iTime(NULL,0,1),",",
                                 iHigh(NULL, 0,1),",",
                                 iLow(NULL,0,1));
                                

   CheckForOpen();
   Print ("InsideStartAfterCheckForOpen");
   return (0);
   }

void CheckForOpen()
{
   int res;
   Print ("InsideCheckForOpen");   
   if(Volume[0]>1) return;
   if(Hour()==0 && Minute()==55 && Seconds()==0) 
   {
      res=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-5000*Point,TakeProfit,"SEMA",0,0,Blue);

   }                          

   {  
       if(Hour()==1 && Minute()==05 && Seconds()==0)   
      { TakeProfit=20; } else { TakeProfit=1000; }

  
   }
}      
 
Sebastian Woźniczka:

Hi! 

I try to create a strategy which works as follows:

- open a Long position at 0:55 am with a very wide TP and SL

- at 1:05 am change TP into the price, at which the current position was initially opened.


Is this possible to create such condition? And if so, could anyone please help me with this? I am sorry if such question has already been asked at the forum, but I can't find such topic anywhere.

I attached the code, which is supposed to open a Long position at 0:55am with wide TP and at 1:05am change TP into 20 pips. How could I edit it, so it would work as I mentioned above?

OrderModify()
 
Sebastian Woźniczka:

Hi! 

I try to create a strategy which works as follows:

- open a Long position at 0:55 am with a very wide TP and SL

- at 1:05 am change TP into the price, at which the current position was initially opened.


Is this possible to create such condition? And if so, could anyone please help me with this? I am sorry if such question has already been asked at the forum, but I can't find such topic anywhere.

I attached the code, which is supposed to open a Long position at 0:55am with wide TP and at 1:05am change TP into 20 pips. How could I edit it, so it would work as I mentioned above?

if(Volume[0]>1) return;
   if(Hour()==0 && Minute()==55 && Seconds()==0) 

You have already been told about this.

https://www.mql5.com/en/forum/428620#comment_40776320

yet you are making exactly the same mistake here.

People won't keep trying to help if you ignore what they say.

Issue with setting specific Buy and Sell time
Issue with setting specific Buy and Sell time
  • 2022.07.13
  • www.mql5.com
Hi! So I have been trying to implement a simple strategy, which I plan to develop further...