Stop Strategy for the day the biggest loss is Hit

Questions about MultiCharts and user contributed studies.
Stanley
Posts: 3
Joined: 16 Apr 2018

Stop Strategy for the day the biggest loss is Hit

Postby Stanley » 13 Aug 2018

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....

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: Stop Strategy for the day the biggest loss is Hit

Postby Smoky » 13 Aug 2018

try this :

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;
reset StopTrading to false on every new trading day...

Stanley
Posts: 3
Joined: 16 Apr 2018

Re: Stop Strategy for the day the biggest loss is Hit

Postby Stanley » 30 Aug 2018

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?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Stop Strategy for the day the biggest loss is Hit

Postby TJ » 30 Aug 2018

See post #1 and post #2
viewtopic.php?t=11713

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Stop Strategy for the day the biggest loss is Hit

Postby TJ » 30 Aug 2018

What is your chart resolution?

Stanley
Posts: 3
Joined: 16 Apr 2018

Re: Stop Strategy for the day the biggest loss is Hit

Postby Stanley » 30 Aug 2018

[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......
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

AVT
Posts: 6
Joined: 30 Aug 2018
Has thanked: 1 time

Re: Stop Strategy for the day the biggest loss is Hit

Postby AVT » 30 Aug 2018

any idea to use this in portfolio trading?


Return to “MultiCharts”