Что будет с рынком при беспроигрышной ТС?
//+------------------------------------------------------------------+
//| Poshnik.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern int StopLoss = 500; // лось
extern int TakeProfit = 500; // язь
extern int Delta = 100; // расстояние от цены
extern int BuySell = 0; // 1-buy 2-sell 0-off
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Установка ордера |
//+------------------------------------------------------------------+
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(OrderType()<2)
count++;
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double MarketOOP()
{
double oop=0;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()<2)
oop=OrderOpenPrice();
}
return(oop);
}
//+------------------------------------------------------------------+
//| Удаление отложенных ордеров |
//+------------------------------------------------------------------+
void DelOrder(int type=-1)
{
bool del;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==type || type==-1)
del=OrderDelete(OrderTicket());
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double MarketLot()
{
double lot=0;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()<2)
lot=OrderLots();
}
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
if(Lots==0)
lot=MarketLot();
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int LastType()
{
int type=8;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()<2)
type=OrderType();
}
return(type);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double StopOOP()
{
double oop=0;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()>1)
oop=OrderOpenPrice();
}
return(oop);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1)
{
DelOrder();
if(BuySell==1)
PutOrder(0,Ask);
if(BuySell==2)
PutOrder(1,Bid);
}
if(MarketOOP()>0 && StopOOP()!=NormalizeDouble(MarketOOP()-Delta*_Point,_Digits) && LastType()==0)
PutOrder(5,MarketOOP()-Delta*_Point);
if(MarketOOP()>0 && StopOOP()!=NormalizeDouble(MarketOOP()+Delta*_Point,_Digits) && LastType()==1)
PutOrder(4,MarketOOP()+Delta*_Point);
}
//+------------------------------------------------------------------+
bool buy = red>blu && red2<blu2 && m15>m152 && m30>m302 && h1>h12;
bool sell = red<blu && red2>blu2 && m15<m152 && m30<m302 && h1<h12;
bool buy = m15>m152 && m30>m302 && h1>h12;
bool sell = m15<m152 && m30<m302 && h1<h12;
hift+1 не подходит, нужно сравнивать текущий бар и «х» минут назад, минуты таймфрейма SSRC Mtf.
Идеальные входы когда все индикаторы смотрят вверх или вниз, у меня на скринах в подвале 3 индикатора, сделайте условия хотя бы для одного, дальше, я сам.
Сейчас у меня так, но это не правильно.
P.S. Советник будет стоять на графиках ренко, поэтому «х» баров назад не подходит, нужно именно минуты, или может брать значение непосредственно с нужного TF.
//+------------------------------------------------------------------+
//| Ishi4.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 = 1; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern int StopLoss = 2000; // лось
extern int TakeProfit = 3000; // язь
extern int Slip = 30; // реквот
extern int Shift = 1; // бар индикатора
extern int CloseSig = 1; // 1-закрытие в конце работы
extern int Magic = 123; // магик
extern string IndName = "KT-Ichimoku-Alerts";
//+------------------------------------------------------------------+
//| 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);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double blu = iCustom(NULL,0,IndName,1,Shift);
double red = iCustom(NULL,0,IndName,0,Shift);
double blu2 = iCustom(NULL,0,IndName,1,Shift+1);
double red2 = iCustom(NULL,0,IndName,0,Shift+1);
if(CountTrades()<1)
{
if(red>blu && red2<blu2)
{
PutOrder(0,Ask);
}
if(red<blu && red2>blu2)
{
PutOrder(1,Bid);
}
}
Comment("\n blu: ",blu,
"\n red: ",red);
}
//+------------------------------------------------------------------+
К сожалению, я не поняла какие значения имеют переменные в тексте программы и не могу понять как происходит расчет.
//+------------------------------------------------------------------+
//| Pointer14.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
#property indicator_chart_window
#property indicator_buffers 2
extern int Count=111;
double up[];
double dn[];
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_ARROW,0,2,Blue);
SetIndexArrow(0,108);
SetIndexBuffer(0,up);
SetIndexStyle(1,DRAW_ARROW,0,2,Red);
SetIndexArrow(1,108);
SetIndexBuffer(1,dn);
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
for(int i=0; i<Count; i++)
{
if(close[i]>close[i+1] && close[i+1]>open[i+1] && low[i]<low[i+1])
{
up[i]=low[i];
}
if(close[i]<close[i+1] && close[i+1]<open[i+1] && high[i]>high[i+1])
{
dn[i]=high[i];
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2