<code>//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
if(OrderProfit()>0)
lot=Lots;
if(OrderProfit()<0)
lot=OrderLots()*KLot;
if(lot>MaxLot)
lot=Lots; // lot=MaxLot; ???????????? Может так лучше?
return(lot);
}
//+------------------------------------------------------------------+
</code>//+------------------------------------------------------------------+
//| dayBreakout.mq4 |
//| Bill Sica |
//| http://www.tetsuyama.com |
//+------------------------------------------------------------------+
#property copyright "Bill Sica"
#property link "http://www.tetsuyama.com"
#property indicator_chart_window
//---- input parameters
extern int DAYS=5;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double daily_high[20];
double daily_low[20];
double phigh,plow;
int i=1;
//---- TODO: add your code here
ArrayResize(daily_high,DAYS);
ArrayResize(daily_low,DAYS);
ArrayInitialize(daily_high,0);
ArrayInitialize(daily_low,0);
ArrayCopySeries(daily_low, MODE_LOW, Symbol(), PERIOD_D1);
ArrayCopySeries(daily_high, MODE_HIGH, Symbol(), PERIOD_D1);
/* initialise */
plow=daily_low[1];
phigh=daily_high[1];
for(i=1;i<DAYS;i++)
{
if(plow>daily_low[i])
{
plow =daily_low[i];
}
}
for(i=1;i<DAYS;i++)
{
if(phigh<daily_high[i])
{
phigh =daily_high[i];
}
}
Comment("\n5dayH ",phigh,"\n5dayL ",plow);
ObjectDelete("5dayHigh");
ObjectDelete("5dayLow");
ObjectCreate("5dayHigh", OBJ_HLINE,0, CurTime(),phigh);
ObjectSet("5dayHigh",OBJPROP_COLOR,SpringGreen);
ObjectSet("5dayHigh",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate("5dayLow", OBJ_HLINE,0, CurTime(),plow);
ObjectSet("5dayLow",OBJPROP_COLOR,Red);
ObjectSet("5dayLow",OBJPROP_STYLE,STYLE_SOLID);
ObjectsRedraw();
return(0);
}
//+------------------------------------------------------------------
all=NormalizeDouble((allBuy — allSell) / (countBuy — countSell),Digits);
//+------------------------------------------------------------------+
//| Автор поделился. |
//+------------------------------------------------------------------+
for(int i = 0; i < ArraySize(st.orders); i++)
{
if(st.orders[i].GetType() == 0)
{
buy_price += st.orders[i].GetCena() * st.orders[i].GetLots();
buy_lot += st.orders[i].GetLots();
t++;
}
if(st.orders[i].GetType() == 1)
{
sel_price += st.orders[i].GetCena() * st.orders[i].GetLots();
sel_lot += st.orders[i].GetLots();
t++;
}
}
price_aw = NormalizeDouble((buy_price - sel_price) / (buy_lot - sel_lot), Digits());
// Превел для себя
//+------------------------------------------------------------------+
//| Превел для себя |
//+------------------------------------------------------------------+
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
{
allBuy+=OrderOpenPrice()*OrderLots();
countBuy+=OrderLots();
countBuy++;
}
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_SELL)
{
allSell+=OrderOpenPrice()*OrderLots();
countSell+=OrderLots();
countSell++;
}
if(countBuy + countSell > 0)
all=NormalizeDouble((allBuy - allSell) / (countBuy - countSell),_Digits);
//+------------------------------------------------------------------+
тут даже проверять нечего. Зачем два раза делите на лоты?
<code>//+------------------------------------------------------------------+
//| Odessa.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.mункцql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.mункцql5.com"
#property version "1.00"
#property strict
extern int TrailingStop = 1000;
extern int Magic = 111; // магик
input color col = clrLime;
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
ObjectsDeleteAll();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--------------AM2
double all=0, all_1=0, all_2=0, all_3=0, all_4=0,count=0,sl=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2)
{
all+=OrderOpenPrice()*OrderLots();
count+=OrderLots();
}
}
}
}
if(count>0) all=NormalizeDouble(all/count,_Digits);// AM2
//--------------------------------------------------------------
//-----------------------Odessa
double allBuy=0,countBuy=0,allSell=0,countSell=0;
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
{
allBuy+=OrderOpenPrice()*OrderLots();
countBuy+=OrderLots();
}
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_SELL)
{
allSell+=OrderOpenPrice()*OrderLots();
countSell+=OrderLots();
}
if(countBuy+countSell>0) all_1=NormalizeDouble((allBuy - allSell) / (countBuy - countSell),_Digits);//Odessa
if(countBuy+countSell>0) all_2=NormalizeDouble((allBuy/countBuy + allSell/countSell) / (countBuy + countSell),_Digits);//Odessa
//-----------------------------------------------------------------------
//------------------------------Сибирь
double allBuy_2=0,countBuy_2=0,allSell_2=0,countSell_2=0;
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
{
allBuy_2+=OrderOpenPrice()*OrderLots();
countBuy_2+=OrderLots();
}
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
if(OrderType()==OP_SELL)
{
allSell_2+=OrderOpenPrice()*OrderLots();
countSell_2+=OrderLots();
}
if(countBuy_2+countSell_2>0) all_3=NormalizeDouble((allBuy_2 + allSell_2) / (countBuy_2 + countSell_2),_Digits);//Сибирь
if(countBuy_2+countSell_2>0) all_4=NormalizeDouble((allBuy_2 - allSell_2) / (countBuy_2 - countSell_2),_Digits);//Сибирь
//-------------------------------------------------------------------
DrawLABEL("AM2",StringConcatenate(count," лотов. БУ AM2 = ",DoubleToStr(all,_Digits)),135,70,col,ANCHOR_LEFT);
DrawLABEL("Odessa1",StringConcatenate(countBuy+countSell," лотов. БУ Odessa 1 = ",DoubleToStr(all_1,_Digits)),135,90,col,ANCHOR_LEFT);
DrawLABEL("Odessa2",StringConcatenate(countBuy+countSell," лотов. БУ Odessa 2 = ",DoubleToStr(all_2,_Digits)),135,110,col,ANCHOR_LEFT);
DrawLABEL("Сибирь1",StringConcatenate(countBuy_2+countSell_2," лотов. БУ Сибирь сложение = ",DoubleToStr(all_3,_Digits)),135,130,col,ANCHOR_LEFT);
DrawLABEL("Сибирь2",StringConcatenate(countBuy_2+countSell_2," лотов. БУ Сибирь вычитание = ",DoubleToStr(all_4,_Digits)),135,150,col,ANCHOR_LEFT);
}
//+------------------------------------------------------------------+
color Color(bool P,color a,color b)
{
if (P) return(a);
else return(b);
}
//------------------------------------------------------------------
void DrawLABEL(string name, string Name, int X, int Y, color clr,ENUM_ANCHOR_POINT align=ANCHOR_RIGHT)
{
if (ObjectFind(name)==-1)
{
ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
ObjectSet(name, OBJPROP_CORNER, 2);
ObjectSet(name, OBJPROP_XDISTANCE, X);
ObjectSet(name, OBJPROP_YDISTANCE, Y);
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
ObjectSetInteger(0,name,OBJPROP_ANCHOR,align);
}
ObjectSetText(name,Name,12,"Arial",clr);
}
//-------------------------------------------------------</code>
И за это моему калькулятору гранд мерси.
kvashnin007