ea dodanie stop loss
ea dodanie stop loss
czy ktoś może mi napisać jak dodać stop loss do tej strategii,i czy się da.dodam że jestem zielony w te klocki
//+------------------------------------------------------------------+
//| SWB_SuperTrend_V1.01.mq4 |
//| Copyright © 2010, Dennis Hamilton |
//| ramble_32@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Dennis Hamilton"
#property link "ramble_32@yahoo.com"
//----
extern string Separator_01="---- Input Settings ----";
extern double lot=0.05;
extern double tp_1=25;
extern double tp_2=25;
extern double StopLoss = 210;
extern int magic=123;
extern int bars_closed=0;
extern string Separator_02="---- Range & Offsets ----";
extern double range=40;
extern int max_level=10;
extern int curb_level=3;
extern double p1_offset=10;
extern double p2_offset=15;
extern int pend_delete=30;
extern double profit_target=20.0;
extern double curb_factor=0.5;
extern bool stealth=false;
extern bool tier2_sig=true;
extern string Separator_03="---- Lot Settings ----";
extern bool lot_multiplier=false;
extern double multiplier=2.0;
extern double increment=0.02;
extern bool power_lots=true;
extern string Separator_04="---- Additional ----";
extern double deviation_reset=0;
extern int reset_level=3;
extern bool closeall=false;
extern bool stop_ea=false;
//----
double pt;
double p_off;
double p1_off;
double p2_off;
double std=0.1;
double AE1;
double p_lot;
double lot2;
double bal_2;
double incr_1;
double b_price;
double s_price;
double d_reset;
int OT;
bool deleteall;
bool hedge=false;
bool b_send;
bool s_send;
string f_trade="NULL";
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
pt=Point; if(Digits==3 || Digits==5) pt=10*Point;
tp_1*=pt;
tp_2*=pt;
range*=pt;
if(p1_offset<5.0) p1_offset=0.0;
if(p2_offset<5.0) p2_offset=0.0;
p1_off=p1_offset*pt;
p2_off=p2_offset*pt;
d_reset=deviation_reset;
if(curb_level<3) curb_level=0;
//----
AE1=AccountEquity(); p_lot=lot/AE1;
if(StringLen(Symbol())>6) std=1.0;
profit_target*=std;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int total=0, t_cnt=0, p_cnt=0, b_cnt=0, s_cnt=0, b2_cnt=0, s2_cnt=0;
int b3_cnt=0, s3_cnt=0; double FOOP, B_LOOP, S_LOOP;
for(int i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
total++;
//----
if(cmd()< 2) t_cnt++;
if(cmd()> 1) p_cnt++;
if(cmd()==0){ b_cnt++; b3_cnt++; } if(cmd()==4){ b2_cnt++; b3_cnt++; }
if(cmd()==1){ s_cnt++; s3_cnt++; } if(cmd()==5){ s2_cnt++; s3_cnt++; }
if(b3_cnt==1 || (b3_cnt>1 && OOP()<B_LOOP)) B_LOOP=OOP();
if(s3_cnt==1 || (s3_cnt>1 && OOP()>S_LOOP)) S_LOOP=OOP();
if(b_cnt ==1 || (b_cnt >1 && OOP()>FOOP)) FOOP=OOP();
if(s_cnt ==1 || (s_cnt >1 && OOP()<FOOP)) FOOP=OOP();
}
//----
string H=""; if(stealth) H="_S"; if(hedge) H="_H"; if(stealth && hedge) H="_SH";
if(total==0) f_trade="Null"+H;
if(t_cnt==0 && p_cnt==1) f_trade="Pend"+H;
if(t_cnt==1 && p_cnt==0){ f_trade="Buy"+H; if(s_cnt==1) f_trade="Sell"+H; }
//+------------------------------------------------------------------+
for(i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
double OTP=OrderTakeProfit(), tp_3=tp_1;
if(cmd()<2 && OTP==0)
{
if(t_cnt>1) tp_3=tp_2; if(cmd()==1) tp_3*=-1;
if(!stealth || (stealth && OrderComment()=="L1")) OTP=OOP()+tp_3;
if(OTP!=0){ OrderModify(OrderTicket(),0,0,OTP,0,CLR_NONE); deleteall=true; }
}
//----
if(t_cnt==0 && pend_delete>0)
{
datetime OOT=OrderOpenTime(), get_time=TimeCurrent();
if(cmd()>1 && get_time-OOT>pend_delete*60) OrderDelete(OrderTicket());
}
}
//+------------------------------------------------------------------+
double o_charts=GlobalVariableGet("open_charts"); o_charts=1; // Global currently by-passed
double AB=AccountBalance(), lot2=lot/o_charts, pl_factor=1/o_charts;
//----
if(power_lots)
{
if(AB>AE1) lot2=NormalizeDouble((p_lot*AB)/o_charts,Digits);
pl_factor=(lot2/lot)/o_charts; double lot3=lot2;
}
//----
double p_targ=profit_target*pl_factor, incr_1=increment*pl_factor, b_lot=lot2, s_lot=lot2;
//+------------------------------------------------------------------+
bool t_buy=false, t_sell=false, t2_buy=false, t2_sell=false;
if((p1_off==0 && t_cnt==0) || (p1_off>0 && b3_cnt==0 && (s_cnt==0 || f_trade=="Buy"+H))) t_buy=true;
if((p1_off==0 && t_cnt==0) || (p1_off>0 && s3_cnt==0 && (b_cnt==0 || f_trade=="Sell"+H))) t_sell=true;
if(f_trade=="Buy"+H && b3_cnt>0 && b_cnt<max_level) t2_buy=true;
if(f_trade=="Sell"+H && s3_cnt>0 && s_cnt<max_level) t2_sell=true;
//----
if(total==0){ closeall=false; b_send=false; s_send=false; }
if(b2_cnt==0 && s2_cnt==0) deleteall=false;
if(!stop_ea && !closeall && !deleteall)
{
if(t_buy || (t2_buy && Ask<=B_LOOP-range-p2_off)) // BUY
{
if(signal()==0 || (b_cnt>0 && !tier2_sig))
{
if(lot_multiplier) b_lot=lot2*MathPow(multiplier,b_cnt);
if(!lot_multiplier) b_lot=lot2+(incr_1*b_cnt);
OT=0; p_off=p1_off;
if(b_cnt>0) p_off=p2_off; if(p_off>0) OT=4;
//----
OrderSend(Symbol(),OT,b_lot,Ask+p_off,3,0,0,"L"+(b_cnt+1),magic,0,Blue);
}
}
//----
if(t_sell || (t2_sell && Bid>=S_LOOP+range+p2_off)) // SELL
{
if(signal()==1 || (s_cnt>0 && !tier2_sig))
{
if(lot_multiplier) s_lot=lot2*MathPow(multiplier,s_cnt);
if(!lot_multiplier) s_lot=lot2+(incr_1*s_cnt);
OT=1; p_off=p1_off;
if(s_cnt>0) p_off=p2_off; if(p_off>0) OT=5;
//----
OrderSend(Symbol(),OT,s_lot,Bid-p_off,3,0,0,"L"+(s_cnt+1),magic,0,Red);
}
}
}
//+------------------------------------------------------------------+
double profit=0, profit_1=0, profit_2=0, profit_3=0, t_lot=0, b2_lot=0, s2_lot=0;
for(i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
profit+=OrderProfit();
if(t_cnt>2 && OT2()=="L")
{
if(OrderComment()=="L"+t_cnt) profit_1=OrderProfit();
if(OrderComment()=="L"+(t_cnt-1)) profit_2=OrderProfit();
profit_3=profit_1+profit_2;
}
if(cmd()< 2) t_lot+=OrderLots();
if(cmd()==0){ b2_lot+=OrderLots(); if(OOP()==FOOP) b_price=OOP(); }
if(cmd()==1){ s2_lot+=OrderLots(); if(OOP()==FOOP) s_price=OOP(); }
}
//----
double dev_b, dev_s, deviate=0;
if(b_cnt>0){ dev_b=b_price-Ask; if(dev_b>0) deviate=dev_b/pt; }
if(s_cnt>0){ dev_s=Bid-s_price; if(dev_s>0) deviate=dev_s/pt; }
//+------------------------------------------------------------------+
for(i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
if(cmd()<2)
{
if(deviate>=d_reset && d_reset>0 && t_cnt>=reset_level)
{
if(OOP()==FOOP)
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
if(t_cnt>=curb_level && profit_3>=p_targ*curb_factor)
{
if(OCM()=="L"+t_cnt || OCM()=="L"+(t_cnt-1))
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
}
}
//+------------------------------------------------------------------+
double balance=0;
for(i=0; i<OrdersHistoryTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
balance+=OrderProfit();
}
//----
if(t_cnt==0) GlobalVariableSet("bal_2"+Symbol()+magic,balance);
bal_2=GlobalVariableGet("bal_2"+Symbol()+magic);
//+------------------------------------------------------------------+
if(balance+profit>=bal_2+p_targ) closeall=true;
if(closeall || deleteall)
{
for(i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
if(closeall) deleteall=true;
if(cmd()>1 && deleteall) OrderDelete(OrderTicket());
if(cmd()<2 && closeall) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
}
//+------------------------------------------------------------------+
string multi="Multiplier = "+DoubleToStr(multiplier,2), tier2="Yes", dev_r="";
if(!lot_multiplier) multi="Increment = "+DoubleToStr(incr_1,2);
if(!tier2_sig) tier2="No"; if(d_reset>0) dev_r=" / "+DoubleToStr(d_reset,0)+" / "+t_cnt+" / "+reset_level;
//----
string line_1="Balance = "+DoubleToStr(bal_2,2)+" | Profit = "+DoubleToStr(bal_2+profit,2)+" | Equity = "+DoubleToStr(AccountEquity(),2)+" | Target = "+DoubleToStr(profit_target,2)+" / "+DoubleToStr(p_targ,2)+" / "+DoubleToStr(profit,2)+"\n";
string line_2="Start Lot = "+DoubleToStr(lot,2)+" | Power lots = "+DoubleToStr(lot3,2)+" | Open = "+b_cnt+" / "+s_cnt+" | Pending = "+b2_cnt+" / "+s2_cnt+" | Deviate = "+DoubleToStr(deviate,0)+dev_r+"\n";
string line_3="OPT = "+f_trade+" | "+multi+" | Spread = "+DoubleToStr((Ask-Bid)/pt,2)+" | Total Lots = "+DoubleToStr(t_lot,2)+" | Tier 2 = "+tier2+"\n";
//----
Comment(line_1, line_2, line_3);
//----
return(0);
}
//+------------------------------------------------------------------+
int cmd()
{ int cmd=OrderType();
return(cmd); }
//----
double OOP()
{ double OOP=OrderOpenPrice();
return(OOP); }
//----
string OCM()
{ string OCM=OrderComment();
return(OCM); }
//----
string OT2()
{ string OT2=StringSubstr(OrderComment(),0,1);
return(OT2); }
//+------------------------------------------------------------------+
int signal()
{
int signal=2;
if(iCustom(NULL,0,"SuperTrend",10,3.0,0,bars_closed)!=EMPTY_VALUE) signal=0;
if(iCustom(NULL,0,"SuperTrend",10,3.0,1,bars_closed)!=EMPTY_VALUE) signal=1;
return(signal);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| SWB_SuperTrend_V1.01.mq4 |
//| Copyright © 2010, Dennis Hamilton |
//| ramble_32@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Dennis Hamilton"
#property link "ramble_32@yahoo.com"
//----
extern string Separator_01="---- Input Settings ----";
extern double lot=0.05;
extern double tp_1=25;
extern double tp_2=25;
extern double StopLoss = 210;
extern int magic=123;
extern int bars_closed=0;
extern string Separator_02="---- Range & Offsets ----";
extern double range=40;
extern int max_level=10;
extern int curb_level=3;
extern double p1_offset=10;
extern double p2_offset=15;
extern int pend_delete=30;
extern double profit_target=20.0;
extern double curb_factor=0.5;
extern bool stealth=false;
extern bool tier2_sig=true;
extern string Separator_03="---- Lot Settings ----";
extern bool lot_multiplier=false;
extern double multiplier=2.0;
extern double increment=0.02;
extern bool power_lots=true;
extern string Separator_04="---- Additional ----";
extern double deviation_reset=0;
extern int reset_level=3;
extern bool closeall=false;
extern bool stop_ea=false;
//----
double pt;
double p_off;
double p1_off;
double p2_off;
double std=0.1;
double AE1;
double p_lot;
double lot2;
double bal_2;
double incr_1;
double b_price;
double s_price;
double d_reset;
int OT;
bool deleteall;
bool hedge=false;
bool b_send;
bool s_send;
string f_trade="NULL";
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
pt=Point; if(Digits==3 || Digits==5) pt=10*Point;
tp_1*=pt;
tp_2*=pt;
range*=pt;
if(p1_offset<5.0) p1_offset=0.0;
if(p2_offset<5.0) p2_offset=0.0;
p1_off=p1_offset*pt;
p2_off=p2_offset*pt;
d_reset=deviation_reset;
if(curb_level<3) curb_level=0;
//----
AE1=AccountEquity(); p_lot=lot/AE1;
if(StringLen(Symbol())>6) std=1.0;
profit_target*=std;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int total=0, t_cnt=0, p_cnt=0, b_cnt=0, s_cnt=0, b2_cnt=0, s2_cnt=0;
int b3_cnt=0, s3_cnt=0; double FOOP, B_LOOP, S_LOOP;
for(int i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
total++;
//----
if(cmd()< 2) t_cnt++;
if(cmd()> 1) p_cnt++;
if(cmd()==0){ b_cnt++; b3_cnt++; } if(cmd()==4){ b2_cnt++; b3_cnt++; }
if(cmd()==1){ s_cnt++; s3_cnt++; } if(cmd()==5){ s2_cnt++; s3_cnt++; }
if(b3_cnt==1 || (b3_cnt>1 && OOP()<B_LOOP)) B_LOOP=OOP();
if(s3_cnt==1 || (s3_cnt>1 && OOP()>S_LOOP)) S_LOOP=OOP();
if(b_cnt ==1 || (b_cnt >1 && OOP()>FOOP)) FOOP=OOP();
if(s_cnt ==1 || (s_cnt >1 && OOP()<FOOP)) FOOP=OOP();
}
//----
string H=""; if(stealth) H="_S"; if(hedge) H="_H"; if(stealth && hedge) H="_SH";
if(total==0) f_trade="Null"+H;
if(t_cnt==0 && p_cnt==1) f_trade="Pend"+H;
if(t_cnt==1 && p_cnt==0){ f_trade="Buy"+H; if(s_cnt==1) f_trade="Sell"+H; }
//+------------------------------------------------------------------+
for(i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
double OTP=OrderTakeProfit(), tp_3=tp_1;
if(cmd()<2 && OTP==0)
{
if(t_cnt>1) tp_3=tp_2; if(cmd()==1) tp_3*=-1;
if(!stealth || (stealth && OrderComment()=="L1")) OTP=OOP()+tp_3;
if(OTP!=0){ OrderModify(OrderTicket(),0,0,OTP,0,CLR_NONE); deleteall=true; }
}
//----
if(t_cnt==0 && pend_delete>0)
{
datetime OOT=OrderOpenTime(), get_time=TimeCurrent();
if(cmd()>1 && get_time-OOT>pend_delete*60) OrderDelete(OrderTicket());
}
}
//+------------------------------------------------------------------+
double o_charts=GlobalVariableGet("open_charts"); o_charts=1; // Global currently by-passed
double AB=AccountBalance(), lot2=lot/o_charts, pl_factor=1/o_charts;
//----
if(power_lots)
{
if(AB>AE1) lot2=NormalizeDouble((p_lot*AB)/o_charts,Digits);
pl_factor=(lot2/lot)/o_charts; double lot3=lot2;
}
//----
double p_targ=profit_target*pl_factor, incr_1=increment*pl_factor, b_lot=lot2, s_lot=lot2;
//+------------------------------------------------------------------+
bool t_buy=false, t_sell=false, t2_buy=false, t2_sell=false;
if((p1_off==0 && t_cnt==0) || (p1_off>0 && b3_cnt==0 && (s_cnt==0 || f_trade=="Buy"+H))) t_buy=true;
if((p1_off==0 && t_cnt==0) || (p1_off>0 && s3_cnt==0 && (b_cnt==0 || f_trade=="Sell"+H))) t_sell=true;
if(f_trade=="Buy"+H && b3_cnt>0 && b_cnt<max_level) t2_buy=true;
if(f_trade=="Sell"+H && s3_cnt>0 && s_cnt<max_level) t2_sell=true;
//----
if(total==0){ closeall=false; b_send=false; s_send=false; }
if(b2_cnt==0 && s2_cnt==0) deleteall=false;
if(!stop_ea && !closeall && !deleteall)
{
if(t_buy || (t2_buy && Ask<=B_LOOP-range-p2_off)) // BUY
{
if(signal()==0 || (b_cnt>0 && !tier2_sig))
{
if(lot_multiplier) b_lot=lot2*MathPow(multiplier,b_cnt);
if(!lot_multiplier) b_lot=lot2+(incr_1*b_cnt);
OT=0; p_off=p1_off;
if(b_cnt>0) p_off=p2_off; if(p_off>0) OT=4;
//----
OrderSend(Symbol(),OT,b_lot,Ask+p_off,3,0,0,"L"+(b_cnt+1),magic,0,Blue);
}
}
//----
if(t_sell || (t2_sell && Bid>=S_LOOP+range+p2_off)) // SELL
{
if(signal()==1 || (s_cnt>0 && !tier2_sig))
{
if(lot_multiplier) s_lot=lot2*MathPow(multiplier,s_cnt);
if(!lot_multiplier) s_lot=lot2+(incr_1*s_cnt);
OT=1; p_off=p1_off;
if(s_cnt>0) p_off=p2_off; if(p_off>0) OT=5;
//----
OrderSend(Symbol(),OT,s_lot,Bid-p_off,3,0,0,"L"+(s_cnt+1),magic,0,Red);
}
}
}
//+------------------------------------------------------------------+
double profit=0, profit_1=0, profit_2=0, profit_3=0, t_lot=0, b2_lot=0, s2_lot=0;
for(i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
profit+=OrderProfit();
if(t_cnt>2 && OT2()=="L")
{
if(OrderComment()=="L"+t_cnt) profit_1=OrderProfit();
if(OrderComment()=="L"+(t_cnt-1)) profit_2=OrderProfit();
profit_3=profit_1+profit_2;
}
if(cmd()< 2) t_lot+=OrderLots();
if(cmd()==0){ b2_lot+=OrderLots(); if(OOP()==FOOP) b_price=OOP(); }
if(cmd()==1){ s2_lot+=OrderLots(); if(OOP()==FOOP) s_price=OOP(); }
}
//----
double dev_b, dev_s, deviate=0;
if(b_cnt>0){ dev_b=b_price-Ask; if(dev_b>0) deviate=dev_b/pt; }
if(s_cnt>0){ dev_s=Bid-s_price; if(dev_s>0) deviate=dev_s/pt; }
//+------------------------------------------------------------------+
for(i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
if(cmd()<2)
{
if(deviate>=d_reset && d_reset>0 && t_cnt>=reset_level)
{
if(OOP()==FOOP)
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
if(t_cnt>=curb_level && profit_3>=p_targ*curb_factor)
{
if(OCM()=="L"+t_cnt || OCM()=="L"+(t_cnt-1))
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
}
}
//+------------------------------------------------------------------+
double balance=0;
for(i=0; i<OrdersHistoryTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
balance+=OrderProfit();
}
//----
if(t_cnt==0) GlobalVariableSet("bal_2"+Symbol()+magic,balance);
bal_2=GlobalVariableGet("bal_2"+Symbol()+magic);
//+------------------------------------------------------------------+
if(balance+profit>=bal_2+p_targ) closeall=true;
if(closeall || deleteall)
{
for(i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
if(closeall) deleteall=true;
if(cmd()>1 && deleteall) OrderDelete(OrderTicket());
if(cmd()<2 && closeall) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
}
//+------------------------------------------------------------------+
string multi="Multiplier = "+DoubleToStr(multiplier,2), tier2="Yes", dev_r="";
if(!lot_multiplier) multi="Increment = "+DoubleToStr(incr_1,2);
if(!tier2_sig) tier2="No"; if(d_reset>0) dev_r=" / "+DoubleToStr(d_reset,0)+" / "+t_cnt+" / "+reset_level;
//----
string line_1="Balance = "+DoubleToStr(bal_2,2)+" | Profit = "+DoubleToStr(bal_2+profit,2)+" | Equity = "+DoubleToStr(AccountEquity(),2)+" | Target = "+DoubleToStr(profit_target,2)+" / "+DoubleToStr(p_targ,2)+" / "+DoubleToStr(profit,2)+"\n";
string line_2="Start Lot = "+DoubleToStr(lot,2)+" | Power lots = "+DoubleToStr(lot3,2)+" | Open = "+b_cnt+" / "+s_cnt+" | Pending = "+b2_cnt+" / "+s2_cnt+" | Deviate = "+DoubleToStr(deviate,0)+dev_r+"\n";
string line_3="OPT = "+f_trade+" | "+multi+" | Spread = "+DoubleToStr((Ask-Bid)/pt,2)+" | Total Lots = "+DoubleToStr(t_lot,2)+" | Tier 2 = "+tier2+"\n";
//----
Comment(line_1, line_2, line_3);
//----
return(0);
}
//+------------------------------------------------------------------+
int cmd()
{ int cmd=OrderType();
return(cmd); }
//----
double OOP()
{ double OOP=OrderOpenPrice();
return(OOP); }
//----
string OCM()
{ string OCM=OrderComment();
return(OCM); }
//----
string OT2()
{ string OT2=StringSubstr(OrderComment(),0,1);
return(OT2); }
//+------------------------------------------------------------------+
int signal()
{
int signal=2;
if(iCustom(NULL,0,"SuperTrend",10,3.0,0,bars_closed)!=EMPTY_VALUE) signal=0;
if(iCustom(NULL,0,"SuperTrend",10,3.0,1,bars_closed)!=EMPTY_VALUE) signal=1;
return(signal);
}
//+------------------------------------------------------------------+
Witam
Tak na wstępie. Na przyszłość umieszczaj kod między znacznikami Code lub jako załączony plik.
Aby w strategii umieścić Stoploss trzeba zmodyfikować dwa fragmenty
-
oraz
zamienić na
oraz
I powinno być Ok ale nie wiem czy jest bo nie sprawdzałem ![Smile :-)](https://forex-nawigator.biz/forum/images/smilies/icon_smile.gif)
pozdrawiam
redart
Tak na wstępie. Na przyszłość umieszczaj kod między znacznikami Code lub jako załączony plik.
Aby w strategii umieścić Stoploss trzeba zmodyfikować dwa fragmenty
-
Kod: Zaznacz cały
OrderSend(Symbol(),OT,b_lot,Ask+p_off,3,0,0,"L"+(b_cnt+1),magic,0,Blue);
Kod: Zaznacz cały
OrderSend(Symbol(),OT,s_lot,Bid-p_off,3,0,0,"L"+(s_cnt+1),magic,0,Red);
Kod: Zaznacz cały
OrderSend(Symbol(),OT,b_lot,Ask+p_off,3,Ask-StopLoss*Point,0,"L"+(b_cnt+1),magic,0,Blue);
Kod: Zaznacz cały
OrderSend(Symbol(),OT,s_lot,Bid-p_off,3,Bid+StopLoss*Point,0,"L"+(s_cnt+1),magic,0,Red);
![Smile :-)](https://forex-nawigator.biz/forum/images/smilies/icon_smile.gif)
pozdrawiam
redart
W dzienniku testera widać wyraźnie, że w momencie modyfikacji zlecenia SL jest kasowany.
W kodzie jest fragment który modyfikuje zlecenie:
i problem jest w "0" na pozycji SL - kasuje SL który były ustawiony.
trzeba wcześniej po orderselect dodać coś w stylu:
i zmienić OrderModify na
w załączniku poprawiony plik. Sprawdź czy działa bo nie sprawdzałem.
W kodzie jest fragment który modyfikuje zlecenie:
Kod: Zaznacz cały
if(OTP!=0){ OrderModify(OrderTicket(),NULL,0,OTP,0,CLR_NONE); deleteall=true; }
trzeba wcześniej po orderselect dodać coś w stylu:
Kod: Zaznacz cały
double OSL=OrderStopLoss();
Kod: Zaznacz cały
if(OTP!=0){ OrderModify(OrderTicket(),NULL,OSL,OTP,0,CLR_NONE); deleteall=true; }
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Ogladalem ten wskaznik - polega on na tym ze na Supertrendzie bierze tylko sygnaly sell.
Najwiekszy problem to taki ze wskaznik ten potrafi brac sell rowniez w mocnych trendach rosnacych. Trzebaby zrobic filtracje w postaci "jesli supertrend wielki jest dol to mozna brac sell". Osobiscie podoba mi sie bardzo wskaznik valuema. Jest to MA na ktora skladaja sie 3 inne MA. Dwie ja definiuja, trzecia okresla czy mozna zmieniac kierunek. Ladna zabawka.
Moznaby sie pokusic o dodanie sygnalow buy.
Najlepiej na edku, M5, z tp okolo 5 punktow.
Wada tego EA o ktorej pisalem wyzej jest taka ze zlapanie zlego sygnalu na odwrotnym trendzie moze doprowadzic do zniszczenia depo 2-3 transakcjami (SL jest tam na 210pips).
Chyba cos se pokombinuje bo fajna maszynka. Ale to pewnie potrwa albo zapomne![Razz :P](https://forex-nawigator.biz/forum/images/smilies/icon_razz.gif)
Przydalby sie emergency close wszystkich zlych transakcji gdy zmiana trendu...
Najwiekszy problem to taki ze wskaznik ten potrafi brac sell rowniez w mocnych trendach rosnacych. Trzebaby zrobic filtracje w postaci "jesli supertrend wielki jest dol to mozna brac sell". Osobiscie podoba mi sie bardzo wskaznik valuema. Jest to MA na ktora skladaja sie 3 inne MA. Dwie ja definiuja, trzecia okresla czy mozna zmieniac kierunek. Ladna zabawka.
Moznaby sie pokusic o dodanie sygnalow buy.
Najlepiej na edku, M5, z tp okolo 5 punktow.
Wada tego EA o ktorej pisalem wyzej jest taka ze zlapanie zlego sygnalu na odwrotnym trendzie moze doprowadzic do zniszczenia depo 2-3 transakcjami (SL jest tam na 210pips).
Chyba cos se pokombinuje bo fajna maszynka. Ale to pewnie potrwa albo zapomne
![Razz :P](https://forex-nawigator.biz/forum/images/smilies/icon_razz.gif)
Przydalby sie emergency close wszystkich zlych transakcji gdy zmiana trendu...
-
- Stały bywalec
- Posty: 37
- Rejestracja: 04 lut 2009, 15:42
Witam.qb11 pisze:znalazłem to "cudo" gdzieś w necie,i działa na podstawie wskaźnika super trend.Nie pisało nic o TF i na jakiej parze grać.narazie na back testach nie wygląda za różowo,jak sprawdze na demo to coś napisze.
Koledzy, nie mogę tego uruchomić. W testerze pojawia sie takie coś "2011.07.11 10:01:08 2011.01.06 14:07 Cannot open file 'C:\Program Files\XTB-Trader FIX\experts\indicators\SuperTrend.ex4' on the EURUSD,H1
Powiedzcie mi proszę czego on odemnie chce
![Smile :)](https://forex-nawigator.biz/forum/images/smilies/icon_smile.gif)
Pozdrawiam
Krzysztof
PS. Jeśli chodzi o sam wskaźnik ST to mam go zapisanego we właściwym miejscu.