Получилось всё не так_как задумывалось
Уточните пожалуйста что не так получилось?
Получилось всё не так_как задумывалось
помогите сделать советник для опционов мультивалютный.нужно использовать мартин и индикатор parabolicSAR.экспитация должна устанавливаться по выбору.
Это мне снова до следующего месяца ждать чтоб заказ сделать
//+------------------------------------------------------------------+
//| Kashtan.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
//--- Inputs
extern double Lots = 0.1; // лот
extern int StopLoss = 500; // лось
extern int TakeProfit = 500; // язь
extern int BuySell = 0; // 0-бай. 1-селл. 2-по очереди
extern int Spread = 20; // спред
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("");
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr;
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;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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()==OP_BUY || OrderType()==OP_SELL) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Last()
{
int type=0;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
type=1;//buy
}
if(OrderType()==OP_SELL)
{
type=2;//sell
}
}
}
return(type);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
int spread=MarketInfo(NULL,MODE_SPREAD);
if(CountTrades()<1 && spread<=Spread)
{
if(BuySell==0)
{
PutOrder(0,Ask);
}
if(BuySell==1)
{
PutOrder(1,Bid);
}
if(BuySell==2)
{
if(Last()==0 || Last()==2) PutOrder(0,Ask);
if((Last()==0 || Last()==1) && CountTrades()<1) PutOrder(1,Bid);
}
}
}
//+------------------------------------------------------------------+
//--- входные параметры
//--- входные параметры
input int count = 50; //количество линий вверх вниз от цены
input int step = 333; //шаг линий
input double pr = 1.4622; //цена от которой пляшем
<code> //+------------------------------------------------------------------+ //| GridBuilder.mq5 | //| Copyright 2015, AM2 | //| https://www.forexsystems.biz | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, AM2" #property link "https://www.forexsystems.biz" #property version "1.00" #property indicator_chart_window //---- для расчёта и отрисовки индикатора использовано ноль буферов #property indicator_buffers 0 //---- использовано всего ноль графических построений #property indicator_plots 0 //--- входные параметры input int count = 50; //количество линий вверх вниз от цены input int step = 333; //шаг линий input double pr = 1.4622; //цена от которой пляшем //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping ObjectsDeleteAll(0,0,OBJ_HLINE); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { Comment(""); ObjectsDeleteAll(0,0,OBJ_HLINE); } //+------------------------------------------------------------------+ //| Создает горизонтальную линию | //+------------------------------------------------------------------+ bool HLine(const string name="HLine",double price=0) { //--- создадим горизонтальную линию if(!ObjectCreate(0,name,OBJ_HLINE,0,0,price)) { Print(__FUNCTION__, ": не удалось создать горизонтальную линию! Код ошибки = ",GetLastError()); return(false); } //--- установим цвет линии ObjectSetInteger(0,name,OBJPROP_COLOR,clrGreen); ObjectSetInteger(0,name,OBJPROP_WIDTH,1); return(true); } //+------------------------------------------------------------------+ //| 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[]) { double price=pr; //--- создадим горизонтальную линию for(int i=0;i<=count;i++) { HLine("HLine"+(string)i,price+step*i*_Point); HLine("HLine"+(string)(i+count+1),price-step*i*_Point); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ </code>
//+------------------------------------------------------------------+
//| NoShadow.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
#include <stdlib.mqh>
//--- Inputs
extern int StopLoss = 500; //лось
extern int TakeProfit = 500; //язь
extern int TrailingStop= 300; //трал
extern int Delta = 10; //размер тени
extern int Slip = 100; //проскальзывание
extern int Magic = 123; //магик
extern double Lots = 0.1; //начальный лот
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//Comment("");
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void OpenPos()
{
bool buy,sell;
double sl=0,tp=0;
int res=0,err=0;
buy=Open[1]>Close[1] && Close[1]-Low[1]<Delta*Point;
sell=Open[1]<Close[1] && High[1]-Close[1]<Delta*Point;
//--- sell conditions
if(sell)
{
if(StopLoss>0) sl=NormalizeDouble(Bid+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(Bid-TakeProfit*Point,Digits);
res=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),Slip,sl,tp,"",Magic,0,Red);
if(res<0)
{
err=GetLastError();
Print("ОШИБКА ВЫСТАВЛЕНИЯ ОРДЕРА SELL: ",err,"(",ErrorDescription(err),")");
} else {
RefreshRates();
}
return;
}
//--- buy conditions
if(buy)
{
if(StopLoss>0) sl=NormalizeDouble(Ask-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(Ask+TakeProfit*Point,Digits);
res=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),Slip,sl,tp,"",Magic,0,Blue);
if(res<0)
{
err=GetLastError();
Print("ОШИБКА ВЫСТАВЛЕНИЯ ОРДЕРА BUY: ",err,"(",ErrorDescription(err),")");
} else {
RefreshRates();
}
return;
}
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Trailing()
{
bool mod;
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
if(Bid-OrderOpenPrice()>TrailingStop*Point)
{
if(OrderStopLoss()<Bid-TrailingStop*Point)
{
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
}
if(OrderType()==OP_SELL)
{
if((OrderOpenPrice()-Ask)>TrailingStop*Point)
{
if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
{
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
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()==OP_BUY || OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1) OpenPos();
if(TrailingStop>0) Trailing();
}
//+------------------------------------------------------------------+
zakaz.opentraders.ru/29844.html
Уточните пожалуйста что не так получилось? Чем более подробно все опишите, тем лучше будет результат.
AM2