Author: Pavel Shukin
Orders Execution
It automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
OrderLimit
ÿþ//+------------------------------------------------------------------+

//|                                                  OrderLimit.mq4  |

//|                                                  Pavel Shukin    |

//|                                              fibo.rich@gmail.com |

//+------------------------------------------------------------------+

#property copyright "Pavel Shukin "

#property link      "fibo.rich@gmail.com"

#property version   "1.00"

#property strict

#property description "C:@8?B CAB0=02;8205B ;8<8B=K9 >@45@ buy 8;8 sell."

#property description "A;8 B5:CI0O (Bid) F5=0 2KH5 (1>;LH5) F5=K, ?> :>B>@>9 1K; 1@>=5= A:@8?B,"

#property description "B> 1C45B CAB0=>2;5= Order BuyLimit."

#property description "A;8 B5:CI0O (Bid) F5=0 =865 (<5=LH5) F5=K, ?> :>B>@>9 1K; 1@>=5= A:@8?B,"

#property description "B> 1C45B CAB0=>2;5= Order SellLimit."



#property script_show_inputs

input  double Lots=0.01;//Volume Position



extern int TakeProfit=40;

extern int StopLoss=20;

input  int Slippage=30;

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

   if(Digits==3 || Digits==5)

     {

      TakeProfit*=10;

      StopLoss*=10;

     }

//--define price setting script

   double PriceClick=NormalizeDouble(WindowPriceOnDropped(),Digits);

//--define current price

   double PriceCurrent=NormalizeDouble(Bid,Digits);

//--CA;>285 opening BuyLimit

   if(PriceClick<PriceCurrent)

     {

      BuyLimit(Lots,PriceClick,Slippage);

     }

//--CA;>285 opening SellLimit

   if(PriceClick>PriceCurrent)

     {

      SellLimit(Lots,PriceClick,Slippage);

     }



  }

//+------------------------------------------------------------------+

//Function for opening BuyLimit

//+------------------------------------------------------------------+

void BuyLimit(double lots,double open_price,int slippage)

  {

   int ticket=OrderSend(Symbol(),OP_BUYLIMIT,lots,open_price,slippage,0,0,"ScriptOrderLimit",0,0,clrNONE);

   if(ticket<0)

      Print("Error opening BuyLimit ",GetLastError());

   else

     {

      double sl=NormalizeDouble(open_price-(StopLoss*Point),Digits);

      double tp=NormalizeDouble(open_price+(TakeProfit*Point),Digits);

      if(!OrderModify(ticket,open_price,sl,tp,0,clrNONE))

         Print("Error Modify order BuyLimit ",GetLastError());

     }



  }

//+------------------------------------------------------------------+

//Function for opening SellLimit

//+------------------------------------------------------------------+

void SellLimit(double lots,double open_price,int slippage)

  {

   int ticket=OrderSend(Symbol(),OP_SELLLIMIT,lots,open_price,slippage,0,0,"ScriptOrderLimit",0,0,clrNONE);

   if(ticket<0)

      Print("Error opening SellLimit ",GetLastError());

   else

     {

      double sl=NormalizeDouble(open_price+(StopLoss*Point),Digits);

      double tp=NormalizeDouble(open_price-(TakeProfit*Point),Digits);

      if(!OrderModify(ticket,open_price,sl,tp,0,clrNONE))

         Print("Error Modify Order SellLimit ",GetLastError());

     }

  }

//+------------------------------------------------------------------+

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 ---