Total Risk Limiter  [SOLVED]

Questions about MultiCharts and user contributed studies.
desire
Posts: 11
Joined: 26 Apr 2014
Has thanked: 5 times

Total Risk Limiter

Postby desire » 01 Dec 2015

Hi,

I have the following codes:
-----------------------------------------------------------------------------------------
ReduceContractSize = Round(currentcontracts * ReductionPercentage, 0);

//Exit Position at Open if Total Risk is More Than Comfortable Level
if ReduceContractSize > 0 and marketposition = 1
then
sell ReduceContractSize contracts next bar open;

if ReduceContractSize > 0 and marketposition = -1
then
buytocover ReduceContractSize contracts next bar Open;
------------------------------------------------------------------------------------------

It does reduce the contracts at open once only. If the 2nd day, the ReduceContractSize > 0, it won't reduce any contracts further.

Can anybody advise what's wrong with the code?

Thank you.

desire
Posts: 11
Joined: 26 Apr 2014
Has thanked: 5 times

Re: Total Risk Limiter  [SOLVED]

Postby desire » 02 Dec 2015

Hi,

I come out with a lengthy codes to solve.
----------------------------------------------------------------------------------------
ReduceContractSize = Round(currentcontracts * ReductionPercentage, 0);

if marketposition = 0
then
MaxRiskHitCount = 0;

if marketposition <> 0 and ReduceContractSize > 0
then
MaxRiskHitCount = MaxRiskHitCount + 1;

//Exit Position at Open if Total Risk is More Than Comfortable Level
if marketposition = 1
then begin
if MaxRiskHitCount = 1 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 2 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 3 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 4 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 5 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 6 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 7 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 8 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 9 then sell ReduceContractSize contracts next bar Open;
if MaxRiskHitCount = 10 then sell ReduceContractSize contracts next bar Open;
end;

if marketposition = -1........


Return to “MultiCharts”