if(Tradebutton==1)
{
if (Conbuy )
{
Buy(Lots,open);
PlotString("多开","多开",Low-5,Yellow,1);
}
if (ConSellShort)
{
SellShort(Lots,open);
PlotString("空开","空开",High+5,Yellow,1);
}
}
// 初始止损
if (marketposition>0 and close[1]<entryprice*(1-Maxloss))
{
sell(0,open);
PlotString("多损","多损",High+5,Yellow,1);
}
if (marketposition<0 and close[1]>entryprice*(1+Maxloss))
{
buytocover(0,open);
PlotString("空损","空损",Low-5,Yellow,1);
}
// 多单盈利离场
if (marketposition>0 and maxpositionprofit>lev3_profit)
{
if (positionprofit<maxpositionprofit*LV3)
{
sell (0,open);
PlotString("多离3","多离3",High+5,Yellow,1);
Tradecontrol=2;
}
}
if (marketposition>0 and maxpositionprofit>lev2_profit)
{
if (positionprofit<maxpositionprofit*LV2)
{
sell (0,open);
PlotString("多离2","多离2",High+5,Yellow,1);
Tradecontrol=1;
}
}
if (marketposition>0 and maxpositionprofit>lev1_profit)
{
if (positionprofit<maxpositionprofit*LV1)
{
sell (0,open);
PlotString("多离1","多离1",High+5,Yellow,1);
}
}
// 空单盈利离场
if (marketposition<0 and maxpositionprofit>lev3_profit)
{
if (positionprofit<maxpositionprofit*LV3)
{
buytocover(0,open);
PlotString("空离3","空离3",Low-5,Yellow,1);
Tradecontrol=2;
}
}
if (marketposition<0 and maxpositionprofit>lev2_profit)
{
if (positionprofit<maxpositionprofit*LV2)
{
buytocover(0,open);
PlotString("空离2","空离2",Low-5,Yellow,1);
Tradecontrol=1;
}
}
if (marketposition<0 and maxpositionprofit>lev1_profit)
{
if (positionprofit<maxpositionprofit*LV1)
{
buytocover(0,open);
PlotString("空离1","空离1",Low-5,Yellow,1);
}
}
//大幅盈利之后暂停交易
if (Tradecontrol==2 and BarsSinceExit<50 )
{
Tradebutton=0;
}else
if (Tradecontrol==1 and BarsSinceExit<30 )
{
Tradebutton=0;
}else
{
Tradebutton=1;
}
End作者: tbheyihao 时间: 2016-1-26 16:45:55
if(DelayTradeBars==0)
{
if (Conbuy )
{
Buy(Lots,open);
PlotString("多开","多开",Low-5,Yellow,1);
}
if (ConSellShort)
{
SellShort(Lots,open);
PlotString("空开","空开",High+5,Yellow,1);
}
}
// 初始止损
if (marketposition>0 and close[1]<entryprice*(1-Maxloss))
{
sell(0,open);
PlotString("多损","多损",High+5,Yellow,1);
}
if (marketposition<0 and close[1]>entryprice*(1+Maxloss))
{
buytocover(0,open);
PlotString("空损","空损",Low-5,Yellow,1);
}
// 多单盈利离场
DelayTradeBars=DelayTradeBars-1;
if (marketposition>0 and maxpositionprofit>lev3_profit)
{
if (positionprofit<maxpositionprofit*LV3)
{
sell (0,open);
DelayTradeBars=50;
PlotString("多离3","多离3",High+5,Yellow,1);
}
}
if (marketposition>0 and maxpositionprofit>lev2_profit)
{
if (positionprofit<maxpositionprofit*LV2)
{
sell (0,open);
PlotString("多离2","多离2",High+5,Yellow,1);
}
}
if (marketposition>0 and maxpositionprofit>lev1_profit)
{
if (positionprofit<maxpositionprofit*LV1)
{
sell (0,open);
PlotString("多离1","多离1",High+5,Yellow,1);
}
}
// 空单盈利离场
if (marketposition<0 and maxpositionprofit>lev3_profit)
{
if (positionprofit<maxpositionprofit*LV3)
{
buytocover(0,open);
DelayTradeBars=50;
PlotString("空离3","空离3",Low-5,Yellow,1);
}
}
if (marketposition<0 and maxpositionprofit>lev2_profit)
{
if (positionprofit<maxpositionprofit*LV2)
{
buytocover(0,open);
PlotString("空离2","空离2",Low-5,Yellow,1);
}
}
if (marketposition<0 and maxpositionprofit>lev1_profit)
{
if (positionprofit<maxpositionprofit*LV1)
{
buytocover(0,open);
PlotString("空离1","空离1",Low-5,Yellow,1);
}
}
End作者: fl1652546 时间: 2016-1-27 13:46:37