Нужно тралить открытые сделки по индикатору, с возможностью задавать всего один параметр индикатора Indicator Period (big=longer trend), если я его вставляю он его не учитывает!
Селл — буфер 1
Бай — буфер 0
тралить только профит
#property version "1.00"
#property strict
int intBars;
//***********************************************************************************************
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//***********************************************************************************************
void OnDeinit(const int reason)
{
//---
}
//***********************************************************************************************
void OnTick()
{
// если появился новый бар:
if(f_IsNewBar()) f_EveryBar();
}
//***********************************************************************************************
void f_EveryBar()
{
// выполняется в начале каждого нового бара
Comment("\n", "Новый бар наступил!");
}
//***********************************************************************************************
bool f_IsNewBar()
{
if(intBars != Bars)
{
intBars = Bars;
return(true);
}
return(false);
}
//**********************************************
<code> extern string IndName = "KT-Ichimoku-Alerts"; extern int Tenkan = 9; // Tenkan-sen extern int Kijun = 26; // Kijun-sen extern int Senkou = 52; // Senkou Span B extern string IndName2 = "SSRC"; //////////////////// //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double blu = iCustom(NULL,0,IndName,"",Tenkan,Kijun,Senkou,7,Shift); double red = iCustom(NULL,0,IndName,"",Tenkan,Kijun,Senkou,8,Shift); double red15 = iCustom(NULL,15,IndName2,"",0,Shift); double red30 = iCustom(NULL,30,IndName2,"",0,Shift); double red60 = iCustom(NULL,60,IndName2,"",0,Shift); double red152 = iCustom(NULL,15,IndName2,"",0,Shift+1); double red302 = iCustom(NULL,30,IndName2,"",0,Shift+1); double red602 = iCustom(NULL,60,IndName2,"",0,Shift+1); if(CountTrades()<1) { if(blu<1000.00 && red15>red152 && red30>red302 && red60>red602) { PutOrder(0,Ask); } if(red<1000.00 && red15<red152 && red30<red302 && red60<red602) { PutOrder(1,Bid); } } if(CloseSig>0) { if(red<1000.00 && red15<red152 && red30<red302 && red60<red602) { CloseAll(0); } if(blu<1000.00 && red15>red152 && red30>red302 && red60>red602) { CloseAll(1); } } Comment("\n blu: ",blu, "\n red: ",red, "\n red15: ",red15, "\n red152: ",red152, "\n red30: ",red30, "\n red302: ",red302, "\n red60: ",red60, "\n red602: ",red602); } </code>
<code>double blu = iCustom(NULL,0,IndName,"",Tenkan,Kijun,Senkou,7,Shift); double red = iCustom(NULL,0,IndName,"",Tenkan,Kijun,Senkou,8,Shift); double red15 = iCustom(NULL,0,IndName2,"",0,Shift); double red30 = iCustom(NULL,0,IndName3,"",0,Shift); double red60 = iCustom(NULL,0,IndName4,"",0,Shift); if(CountTrades()<1) { if(blu<1000 && red15>red30 && red30>red60) { PutOrder(0,Ask); } if(red<1000 && red15<red30 && red30<red60) { PutOrder(1,Bid); } }</code>
<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>
double blu = iCustom(NULL,0,IndName,5,Shift);
double red = iCustom(NULL,0,IndName,6,Shift);
Comment("\n blu: ",blu,
"\n red: ",red,);
alekseifx