Adv_sell_stop_script

Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
Adv_sell_stop_script
//+------------------------------------------------------------------+
//| script "send pending buy stop order with expiration data"
//| Variable spacing function added   
//| Variable TP function added
//+------------------------------------------------------------------+
int start()
  {
   int    ticket,expiration;
   double point;
   // change the a value to set how many buy stop pending order
   int a = 20; 
   // change the b value to set your lot size
   double b = 1; 
   // change the c value to set how many hours from now until your pending expired
   double c = 240;
   // change the d value to set the spacing for the first position from the current ask price
   int d = 10;
   // you can change this e value with your expected price
   double e = Ask ; 
   // change the f value to set the spacing for the second position upward 
   int f = 20;
   // change the g value to set your take profit
   int g = 20;
 //----
   point=MarketInfo(Symbol(),MODE_POINT);
   expiration=CurTime()+PERIOD_D1*(c*2.5);
   for(int i=a;i>=0;i--)

//----
   while(true)
     {
      ticket=OrderSend(Symbol(),OP_SELLSTOP,b,e+(d*point),0,0,e+((d+g)*point),"some comment",22222,expiration,Green);
      d=d+f;
      if(ticket<=0) Print("Error = ",GetLastError());
      else { Print("ticket = ",ticket); break; }
      //---- 5 seconds wait
      Sleep(5000);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---