<code>extern int DistancePoints =1; extern bool AllowLoss =true; input int AccuracyPoints =1; input double SARstep =0.02; input double SARmaximum =0.2; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { Print("SAR Trail v.4 Copyright © 2009, Maxim Markov marmax@mail.ru"); return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double Distance =DistancePoints*Point; double Accuracy =AccuracyPoints*Point; double StopCurrent =0; double StopRequired =0; double StopAllowed =0; double StopSet =0; double Spread =MarketInfo(Symbol(), MODE_SPREAD)*Point; double Minimum_Distance =MarketInfo(Symbol(), MODE_STOPLEVEL)*Point; bool m=1; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==FALSE) break; if(OrderSymbol()==Symbol()) { StopCurrent=OrderStopLoss(); if((OrderType()==OP_BUY) && (Close[0]>iSAR(NULL,0,SARstep,SARmaximum,0))) { StopRequired=iSAR(NULL,0,SARstep,SARmaximum,0)-Distance; StopAllowed=Close[0]-Minimum_Distance; StopSet=MathMin(StopAllowed,StopRequired); if((StopSet>StopCurrent+Accuracy) && (StopRequired>=OrderOpenPrice() || AllowLoss)) m=OrderModify(OrderTicket(),OrderOpenPrice(),StopSet,OrderTakeProfit(),0); } if((OrderType()==OP_SELL) && (Close[0]<iSAR(NULL,0,SARstep,SARmaximum,0))) { StopRequired=iSAR(NULL,0,SARstep,SARmaximum,0)+Spread+Distance; StopAllowed=Close[0]+Spread+Minimum_Distance; StopSet=MathMax(StopAllowed,StopRequired); if(((StopSet<StopCurrent-Accuracy) || (StopCurrent==0)) && (StopRequired<=OrderOpenPrice() || AllowLoss)) m=OrderModify(OrderTicket(),OrderOpenPrice(),StopSet,OrderTakeProfit(),0); } } } return(0); }</code>
Но я просил трал только профита!
И не привязывать к Magic
Я просто хотел узнать, возможно ли это сделать
//+------------------------------------------------------------------+
//| Ugol.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
input int bars=500;
input int count=10;
double ind[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_LINE,0,2,Yellow);
SetIndexBuffer(0,ind);
//---
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<bars; i++)
{
ind[i]=(close[i]-close[i+count])/_Point/count;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Кто нибудь встречал советник, выполненный по всем правилам индикатора Ишимоку?
marattmb