龙听期货论坛's Archiver

龙听 发表于 2022-11-7 10:56

MultiCharts-加仓与分批出场

今天来教教大家如何根据各种状况来加仓进场或分批出场,

1.相同条件下的加仓:[code]if  condition1  then buy next bar at market;[/code]加仓设置

[img]http://p.algo2.net/2022/1107/790b81c0feaa3.png[/img]

加仓效果(这示范的condition1=close>o):

[img]http://p.algo2.net/2022/1107/a6fa008838bcf.png[/img]

2.不同条件加仓[code]if  condition1  then buy(“entry”) next bar at market;
if  condition2  then buy(“jiacang1”) next bar at market;
if  condition3  then buy(“jiacang2”)  next bar at market;  [/code]这个的[code]condition1 =close>o and marketposition=0
condition2 =close>o and close[1]>open[1]
condition3 =close>o and close[1]>open[1] and close[2]>open[2]
[/code]加仓设置:

[img]http://p.algo2.net/2022/1107/ba285c649ecb0.png[/img]

加仓效果:
[img]http://p.algo2.net/2022/1107/3a25fc7e1bf7d.png[/img]

3. 同一笔入场的多手持仓的相同条件的分笔出场
分批出场开关:SameExitFromOneEntryOnce[code]if close>o then buy 3 shares  next bar at market;
[SameExitFromOneEntryOnce = false];
if close<o then sell 1 Contracts Next Bar At market;[/code]分批出场效果

[img]http://p.algo2.net/2022/1107/1756407e59c5f.png[/img]

4. 同一笔入场的多手持仓的不同条件的分笔出场[code]if condition1 then sell 1 Contracts total Next Bar At market;
if condition2 then sell 1 Contracts total Next Bar At market;
if condition3  then sell 1 Contracts total Next Bar At market;[/code]通过total 每次固定只平1手

平仓效果
[img]http://p.algo2.net/2022/1107/21f7615a825ac.png[/img]

5. 不同进场或不同条件不同入场名称的分批出场(按进场名称出场),[code]
if  close>o and marketposition=0   then buy ("entry") next bar at market;
if  close>o and close[1]>open[1]   then buy ("jiacang1") next bar at market;
if  close>o and close[1]>open[1] and close[2]>open[2]  then buy ("jiacang2")  next bar at market;

if close[1]<open[1] then begin
   sell from entry("entry") next bar at market;
   sell from entry("jiacang1") next bar at market;
   sell from entry("jiacang2") next bar at market;
end;
[/code]出场效果 :
[img]http://p.algo2.net/2022/1107/ade637a3aced9.png[/img]

页: [1]