请老师将其改成文华使用 (文华财经WH8赢智V8.2)

投资者咨询:请老师将其改成文华使用 (文华财经WH8赢智V8.2)
来源:文华财经  日期:2018-7-18 17:24
 Inputs:
len1(20),len2(33),len4(6),len5(22),len6(20),len7(50);

variables:
UpBand(0),DownBand(0),countband(0),counttrades(0),buytrades(0),selltrades(0),level1(0),level2(0),level3(0),level4(0),level5(0),level6(0),level7(0);

if time_s>93000 then 
begin
if countband=0 then 
begin
UpBand=Highest(high,20)[1];
DownBand=lowest(low,20)[1];
countband=1;
end;
if counttrades<200 then 
begin

if close crosses over UpBand and time_s<145000 and ADX(20)>len2 and AverageFC(close,len4)>AverageFC(close,len5)  and AvgTrueRange(len6)>AverageFC(AvgTrueRange(len6)[1],len7)
then
begin
buy 1 shares next bar at market;
counttrades=counttrades+1;
 buytrades=buytrades+1;
end;

if close crosses under DownBand and time_s<145000 and ADX(20)>len2 and AverageFC(close,len4)<AverageFC(close,len5) and AvgTrueRange(len6)>AverageFC(AvgTrueRange(len6)[1],len7)
then
begin
sellshort 1 shares next bar at market;
counttrades=counttrades+1;
selltrades=selltrades+1;
end;

end;

 condition1=(AverageFC(close,len4)>AverageFC(close,len5)and marketposition=-1); 
 condition2=(AverageFC(close,len4)<AverageFC(close,len5)and marketposition=1); 
 
 switch(contractprofit)
 begin   
  case 4500 to 10000 :
  level1=1;
  print(currentbar,"----","level1");
  case 10001 to 20000:
  level1=0;level2=1;
  print(currentbar,"----","level2");
  case 20001 to 30000:
  level2=0;level3=1;
  print(currentbar,"----","level3");
  case 30001 to 50000:
  level3=0;level4=1;
  print(currentbar,"----","level4");
  case 50001 to 70000:
 level4=0;level5=1;
 print(currentbar,"----","level5");
  case 70001 to 90000:
  level5=0;level6=1;
  print(currentbar,"----","level6");
  case 90001 to 140000:
  level6=0;level7=1;
  print(currentbar,"----","level7");
end;
 
 if condition1 or condition2 
 then begin
switch(contractprofit)
 begin   
  case 4500 to 10000 :
  if level1=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.7);
  print(currentbar,"----","level1=1 and 4500 to 10000 ");
  end;
  case 10001 to 20000 :
  if level2=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.55);
  print(currentbar,"----","level2=1 and 10001 to 20000 ");
  end;
  case 20001 to 30000 :
  if level3=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.45);
  print(currentbar,"----","level3=1 and 20001 to 30000 ");
  end;
  case 30001 to 50000 :
  if level4=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.35);
  print(currentbar,"----","level4=1 and 30001 to 50000  ");
  end;
  case 50001 to 70000 :
  if level5=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.25);
  print(currentbar,"----","level5=1 and 50001 to 70000  ");
  end;
  case 70001 to 90000 :
  if level6=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.20);
  print(currentbar,"----","level6=1 and 70001 to 90000   ");
  end;
  case 90001 to 140000 :
  if level7=1 then begin
  setdollartrailing(maxpositionprofit(0)*0.10);
  print(currentbar,"----","level7=1 and 90001 to 140000    ");
  end;
end;
        
end;

{if contractprofit>10000 then 
begin
 setdollartrailing(maxpositionprofit(0)*0.30);

end;
}

setstoploss((UpBand-DownBand)*300);
 if contractprofit<-6000 then
 begin
 
 setstoploss(8000);

end;
//setstoploss(10000);
//setstoploss(0.2*atr(14)[1]*300);
//setstoploss(0.12*atr(14)[1]*300);
//setstoploss(6000);



if marketposition=0 then
begin
countband=0;

end;

if time_s>145800 then
begin
sell 1 share next bar at market;
buytocover 1 share next bar at market;
countband=0;
counttrades=0;
buytrades=0;
selltrades=0;
end;


end;

技术人员回复
日期:2018-7-18 17:47
您的源码与文华语言差异较大,含有SWITCH语句目前无法改写

您可以说明下思路,我们直接帮您编写