
Comment("Waddah Attar Pivot");
Comment("Waddah Attar Pivot");
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
double fGetLots(void)
{
double lot=Lots;
if(Auto_Risk > 0.0)
{
if(MM_Depo == 0)
{
double TickValue = (MarketInfo(_Symbol, MODE_TICKVALUE) == 0 ? 1 : MarketInfo(_Symbol, MODE_TICKVALUE));
double Balance = MathMin(AccountEquity(),AccountBalance());
lot = (MathMax(minlot, MathMin(maxlot,
MathFloor(Balance*Auto_Risk/100/TickValue/(Stop_Loss*old_point/Point)/lotstep) * lotstep)));
}
else
{
lot = NormalizeDouble(Lots * MathFloor(MathMin(AccountBalance(),AccountEquity())/MM_Depo), 2);
lot = MathMin(MathMax(lot, minlot), maxlot); //сравнение полученнго лота с минимальным/максимальным.
}
}
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol())
{
if(OrderProfit()>0)
break;
if(OrderProfit()<0)
{
lot=OrderLots()*2;
break;
}
}
}
}
if(lot>5)
lot=Lots;
return lot;
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
ATR HiLo Channel Arrows TT EURUSD,H1: array out of range in 'ATR HiLo Channel Arrows TT.mq4' (169,15)
//+------------------------------------------------------------------+
//| ATRHilo.mq4 |
//| Copyright 2021, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double KLot = 2; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern int StopLoss = 2000; // лось
extern int TakeProfit = 3000; // язь
extern int Count = 7; // свечи для проверки
extern int Slip = 30; // реквот
extern int Shift = 1; // бар индикатора
extern int CloseSig = 1; // 1-закрытие по сигналу
extern int Magic = 123; // магик
extern string IndName = "StepMA NMC v3.01";
extern string TimeFrame = "Current time frame";
extern int PdfMaLength = 10; // Pdfma Length
extern double Sensitivity = 5; // Sensivity Factor
extern double StepSize = 2; // Constant Step Size
extern double Variance = 1; // Pdfma variance
extern double Mean = 0.0; // Pdfma mean
extern int Shif = 0; // OShify
extern string IndName2 = "ATR HiLo Channel Arrows TT";
input int p = 10; // Период
input int s = 5; // Угол наклона
input double distance = 2.0; // Ширина канала
input bool showBb = true; // Границы канала
input bool showCl = true; // Центральная линия
input int barsig = 1; // Сигнальная свеча (номер)
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0)
sl=NormalizeDouble(price+StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(price-TakeProfit*_Point,_Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0)
sl=NormalizeDouble(price-StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(price+TakeProfit*_Point,_Digits);
}
r=OrderSend(NULL,type,Lot(),NormalizeDouble(price,_Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=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)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderProfit()>0)
break;
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
break;
}
}
}
}
if(lot>MaxLot)
lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
{
bool cl;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==0 && (ot==0 || ot==-1))
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,_Digits),Slip,White);
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,_Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Sig(int type)
{
int n=0;
for(int i=0; i<Count; i++)
{
double gold = iCustom(NULL,0,IndName2,p,s,distance,4,i);
double magen = iCustom(NULL,0,IndName2,p,s,distance,5,i);
if(type==0 && gold!=EMPTY_VALUE)
n++;
if(type==1 && magen!=EMPTY_VALUE)
n++;
}
return(n);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double lim = iCustom(NULL,0,IndName,TimeFrame,PdfMaLength,Sensitivity,StepSize,Variance,Mean,Shif,3,Shift);
double red = iCustom(NULL,0,IndName,TimeFrame,PdfMaLength,Sensitivity,StepSize,Variance,Mean,Shif,4,Shift);
bool buy = lim!=EMPTY_VALUE && Sig(0)>0;
bool sell = red!=EMPTY_VALUE && Sig(1)>0;
if(CountTrades()<1)
{
if(buy)
{
PutOrder(0,Ask);
}
if(sell)
{
PutOrder(1,Bid);
}
}
if(CloseSig>0)
{
if(buy)
{
CloseAll(1);
}
if(sell)
{
CloseAll(0);
}
}
Comment("\n lime: ",lim,
"\n red: ",red,
"\n Gold: ",Sig(0),
"\n Magen: ",Sig(1));
}
//+------------------------------------------------------------------+
интересно, попробую найти такую настройкуэто приблизительное тестирование, часто такие графики рисует
Вы можете сделать, чтобы сетка была динамическая и двигалась за ценой?по какому алгоритму? я сделал через удаление ордеров
AM2