if d<> d[1] then begin
netprofit = 0;
if netprofit <= -1000 and marketprosition <> 0 then begin
sell 1 contract next bar at market;
buytocover 1 contract next at market;
stopcontract;
setexitclose;
end;
end;
Am I right? the code seems that it doesn't work...
My strategy keep trading a lot times even if my netprofit go down to be -3XXX....
Stop Strategy for the day the biggest loss is Hit
- Smoky
- Posts: 518
- Joined: 03 Dec 2010
- Location: Thailand
- Has thanked: 99 times
- Been thanked: 121 times
Re: Stop Strategy for the day the biggest loss is Hit
try this :
reset StopTrading to false on every new trading day...
Code: Select all
setexitonclose;
if netprofit <= -1000 then StopTrading=True;
//standard trading
if Stoptrading=false then
begin
// buy order
//sell order
end;
//...............
if Stoptrading=true then
begin
//close all for this day
end;
Re: Stop Strategy for the day the biggest loss is Hit
reset StopTrading to false on every new trading day...
----------------------------------
is there any way can stopping the trade when the biggest loss is Hit , but no need to reset the stoptrading to false?
----------------------------------
is there any way can stopping the trade when the biggest loss is Hit , but no need to reset the stoptrading to false?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Stop Strategy for the day the biggest loss is Hit
[IntrabarOrderGeneration = false]
Input:win(900),loss(650),re_pt(50),re_ct(50), maxloss(-2000);
variables: stopentry(4), stoptrading(false),trade_T(true);;
..
.
.
.
condition8=EntriesToday(date) < stopentry;
if d<>d[1] then
trade_T=true;
stoptrading = false;
if netprofit + i_ClosedEquity + openpositionprofit <= maxloss then
stoptrading = true;
if stoptrading = true then begin
if marketposition = 1 and entryname="Entrybuy" then begin
sell("Exit_loss Buy") next bar at market ;
end else if marketposition = -1 and entryname= "reversed sell" then begin
buytocover ("Exit_loss Sell") next bar at market ;
trade_T=false;
end;
end;
if trade_T=true then begin;
if time_s >= 092000 and time_s <= 162444 then begin
if condition1 and condition2 and condition5 and condition8 then begin
buy("Entrybuy") 1 contract next bar at market;
end;
if entryname="Entrybuy" and openpositionprofit <= -500 then begin
sellshort("reversed sell") 1 contract next bar at PosTradeEntryPrice(0, currentcontracts-1) - re_pt stop;
end else begin
buytocover ("RS_Exit") 1 contract next bar at PosTradeEntryPrice(0, currentcontracts-1) + re_ct stop;
end;
end else if T=1625 then begin
sell ("close Buy") next bar at market;
buytocover ("close Sell") next bar at market;
end;
end;
setstopcontract;
setexitonclose;
setprofittarget(800);
-------------------------------------
My chart seems ok......but my backtesting is full of the "exitlossbuy" signal......
Input:win(900),loss(650),re_pt(50),re_ct(50), maxloss(-2000);
variables: stopentry(4), stoptrading(false),trade_T(true);;
..
.
.
.
condition8=EntriesToday(date) < stopentry;
if d<>d[1] then
trade_T=true;
stoptrading = false;
if netprofit + i_ClosedEquity + openpositionprofit <= maxloss then
stoptrading = true;
if stoptrading = true then begin
if marketposition = 1 and entryname="Entrybuy" then begin
sell("Exit_loss Buy") next bar at market ;
end else if marketposition = -1 and entryname= "reversed sell" then begin
buytocover ("Exit_loss Sell") next bar at market ;
trade_T=false;
end;
end;
if trade_T=true then begin;
if time_s >= 092000 and time_s <= 162444 then begin
if condition1 and condition2 and condition5 and condition8 then begin
buy("Entrybuy") 1 contract next bar at market;
end;
if entryname="Entrybuy" and openpositionprofit <= -500 then begin
sellshort("reversed sell") 1 contract next bar at PosTradeEntryPrice(0, currentcontracts-1) - re_pt stop;
end else begin
buytocover ("RS_Exit") 1 contract next bar at PosTradeEntryPrice(0, currentcontracts-1) + re_ct stop;
end;
end else if T=1625 then begin
sell ("close Buy") next bar at market;
buytocover ("close Sell") next bar at market;
end;
end;
setstopcontract;
setexitonclose;
setprofittarget(800);
-------------------------------------
My chart seems ok......but my backtesting is full of the "exitlossbuy" signal......
- Attachments
-
- 螢幕截圖 2018-08-30 23.23.39.png
- (60.99 KiB) Downloaded 887 times
-
- 螢幕截圖 2018-08-30 23.18.18.png
- (53.5 KiB) Downloaded 887 times
-
- 螢幕截圖 2018-08-30 23.17.29.png
- (128.53 KiB) Downloaded 887 times