lot_rebate_calculator

Author: Copyright � 2015, MetaQuotes Software Corp.
lot_rebate_calculator
Orders Execution
Checks for the total of closed orders
0 Views
0 Downloads
0 Favorites
lot_rebate_calculator
//+------------------------------------------------------------------+
//|                                               Lot Calculator.mq4 |
//|                      Copyright © 2015, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
#property show_confirm
#property show_inputs

extern string StartDate="2016.04.01";
extern double RebatePerLot=6;
extern color  TColor=clrRed;

int ticket;
int OpType;
double asbid,TP;
double JarLevel;

double totlots;
//+------------------------------------------------------------------+
//| script "send pending order with expiration data"                 |
//+------------------------------------------------------------------+
int start()
  {

   datetime iStart=StringToTime(StartDate);

   totlots=0;
   for(int cnt=0; cnt<OrdersHistoryTotal(); cnt++)
     {
      if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==True)
        {
         if(OrderTicket()>0 && OrderCloseTime()>=iStart && (OrderType()==OP_BUY || OrderType()==OP_SELL))
           {
            totlots=totlots+OrderLots();
           }
        }
     }
   double myRebate=RebatePerLot*totlots;

// Comment("\n\n\n. . . TOTAL LOTS : ",totlots,
//          "\n. . . Rebte/Lots  : $ ",RebatePerLot,
//      "\n. . . my Rebate : $ ",myRebate);

   dpkfx();

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void dpkfx()
  {
   int ipos=3;
   int xpos=30;

   double myRebate=RebatePerLot*totlots;

   int st=1;
   stats("d","Start Date : "+StartDate,9,"Arial",TColor,ipos,xpos-1,65);
   stats("a","TOTAL LOTS : "+DoubleToStr(totlots,2),9,"Arial",TColor,ipos,xpos-1,50);
   stats("b","Rebate / Lots  : $ "+DoubleToStr(RebatePerLot,2),9,"Arial",TColor,ipos,xpos,35);
   stats("c","my Rebate : $ "+DoubleToStr(myRebate,2),9,"Arial",TColor,ipos,xpos-1,20);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void stats(string tname,string word,int fsize,string ftype,color tcolor,int posxy,int posx,int posy)
  {
   ObjectCreate(tname,OBJ_LABEL,0,0,0);
   ObjectSetText(tname,word,fsize,ftype,tcolor);
   ObjectSet(tname,OBJPROP_CORNER,posxy);
   ObjectSet(tname,OBJPROP_XDISTANCE,posx);
   ObjectSet(tname,OBJPROP_YDISTANCE,posy);
  }
//+------------------------------------------------------------------+

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