Author:
Orders Execution
It can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
movepos
ÿþ//+------------------------------------------------------------------+

//|                                                      ProjectName |

//|                                      Copyright 2012, CompanyName |

//|                                       http://www.companyname.net |

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

#property copyright ""

#property link      ""

#property description "!>25B=8: ?5@5428305B >B;>65==K9 >@45@ =0 C:070==>5 :>;8G5AB2>"

#property description "?C=:B>2 ?>A;5 ?>O2;5=8O C:070==>3> :>;8G5AB20 A25G59."

#property strict

//--- input parameters

input int    kolpunktov; // >;8G5AB2> ?C=:B>2

input int    kolsvechei; // >;8G5AB2> A25G59

input string pos; // buy 8;8 sell <0;5=L:8<8 1C:20<8



int m,kols;

bool b;

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

//| Expert initialization function                                   |

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

int OnInit()

  {

   m = TimeHour(Time[0]);

   b = true;

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//---



  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

   if(TimeHour(Time[0])>m)

     {

      m=TimeHour(Time[0]);

      ++kols;

      b=true;

      if(kols==kolsvechei)

        {

         kols=0;

         if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)

           {

            if(pos=="buy") OrderModify(OrderTicket(),NormalizeDouble(OrderOpenPrice()-Point*kolpunktov,Digits),NormalizeDouble(OrderStopLoss()-Point*kolpunktov,Digits),NormalizeDouble(OrderTakeProfit()-Point*kolpunktov,Digits),0,Blue);

            else OrderModify(OrderTicket(),NormalizeDouble(OrderOpenPrice()+Point*kolpunktov,Digits),NormalizeDouble(OrderStopLoss()+Point*kolpunktov,Digits),NormalizeDouble(OrderTakeProfit()+Point*kolpunktov,Digits),0,Blue);

           }

        }

     }

   if(TimeHour(Time[0])==0 && b==true)

     {

      b = false;

      m = TimeHour(Time[0]);

      ++kols;

      if(kols==kolsvechei)

        {

         kols=0;

         if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)

           {

            if(pos=="buy") OrderModify(OrderTicket(),NormalizeDouble(OrderOpenPrice()-Point*kolpunktov,Digits),NormalizeDouble(OrderStopLoss()-Point*kolpunktov,Digits),NormalizeDouble(OrderTakeProfit()-Point*kolpunktov,Digits),0,Blue);

            else OrderModify(OrderTicket(),NormalizeDouble(OrderOpenPrice()+Point*kolpunktov,Digits),NormalizeDouble(OrderStopLoss()+Point*kolpunktov,Digits),NormalizeDouble(OrderTakeProfit()+Point*kolpunktov,Digits),0,Blue);

           }

        }

     }

  }

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

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