что такое дельта?
Дельта расстояние между ордерами
что такое дельта?
А если установить время работы советника и выставлять на евро-американскую сессию
//+------------------------------------------------------------------+
//| ProboyFibo.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 = 0; // стоп лосс ордера
extern int TakeProfit = 0; // тейк профит ордера
extern int Expiration = 24; // время истечения ордера в часах
extern int Slip = 3; // реквот
extern int Magic = 123; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price, double stop, double take)
{
int r=0;
color clr=clrNONE;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits); else sl=NormalizeDouble(stop,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits); else tp=NormalizeDouble(take,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits); else sl=NormalizeDouble(stop,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits); else tp=NormalizeDouble(take,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*3600,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()==0 || OrderType()==1) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
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()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double open=iOpen(NULL,PERIOD_D1,0);
if(CountTrades()<1)
{
if(CountOrders(4)<1)
{
PutOrder(4,open+0.0034,open,open+0.0089);
PutOrder(4,open+0.0089,open,open+0.0144);
PutOrder(4,open+0.0144,open,open+0.0233);
}
if(CountOrders(5)<1)
{
PutOrder(5,open-0.0034,open,open-0.0089);
PutOrder(5,open-0.0089,open,open-0.0144);
PutOrder(5,open-0.0144,open,open-0.0233);
}
}
}
//+------------------------------------------------------------------+
HL1 = 1.6447 + 0.0034 = 1.6481
HL2 = 1.6447 + 0.0089 = 1.6536
HL3 = 1.6447 + 0.0144 = 1.6591
HL4 = 1.6447 + 0.0233 = 1.6680
HL5 = 1.6447 — 0.0034 = 1.6413
HL6 = 1.6447 — 0.0089 = 1.6358
HL7 = 1.6447 — 0.0144 = 1.6303
HL8 = 1.6447 — 0.0233 = 1.6214
Прости меня клинит, то пробой то мартин
//+------------------------------------------------------------------+
//| Delta.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, AM2"
#property link "http://www.forexsystems.biz"
#property description "Forex expert advisor"
//--- Inputs
extern int StopLoss = 333; // лось
extern int TakeProfit = 333; // язь
extern int Delta = 33; // расстояние от цены до ордера
extern int BuySell = 0; // 0-оба 1-бай 2-селл
extern int Slip = 3; // проскальзывание ордера
extern int TickVolume = 3333; // тиковый объем
extern double Lots = 0.3; // объем позиции
extern int Magic = 333; // магик
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DelOrders()
{
bool del=true;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderMagicNumber()==Magic || OrderSymbol()==Symbol())
{
if(OrderType()>3) del=OrderDelete(OrderTicket());
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
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()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
long v = iVolume(NULL,0,1);
if(CountTrades()<1 && v>TickVolume)
{
if((BuySell==0 || BuySell==1) && CountOrders(4)<1) PutOrder(4,Ask+Delta*Point);
if((BuySell==0 || BuySell==2) && CountOrders(5)<1) PutOrder(5,Ask-Delta*Point);
}
if(CountTrades()>0) DelOrders();
Comment("\n Volume: ",v);
}
//+------------------------------------------------------------------+
Имеется в виду, что есть выбор функция Ttue/False если True то отложенные ордера сохраняются N количество дней, если False, то ордера удаляются в конце дня.
Как только стоп оказывается на уровне без убытка, должен выставляться отложенный ордер или несколько ордеров, но теперь уже в противоположном направление если сработал Buy Stop и перевёлся в без убыток то выставляется Sell Stop и наоборот на уровне стоп-лосса этого ордера (или на уровне открытия ордера или ордеров).
Для этих обратных ордеров должны быть свои стоп-лосс и тейк профит.
Здравствуйте могли бы подправить условия,
1 ордера выставляются при достижении определенного тикового обьема
2 возможность выбора устанавливаемого ордера ,( бай стоп или сел стоп)
вывести эти параметры в окно настроек
к примеру заранее выставляю в советнике бай или сел стоп с определенным значением обьема тп и стопом — при появлении нового бара появился обьем равный указанному в настройках и ордер выставлен.
//+------------------------------------------------------------------+
//| BuySell.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 double KLot = 2; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern int StopLoss = 333; // лось
extern int TakeProfit = 333; // язь
extern int BuySell = 0; // 0-Buy 1-Sell
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
//+------------------------------------------------------------------+
//| 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;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
}
}
}
if(lot>MaxLot)lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1)
{
if(BuySell<1) PutOrder(0,Ask);
if(BuySell>0) PutOrder(1,Bid);
}
}
//+------------------------------------------------------------------+
AM2