Advertisement
Maurizio-Ciullo

Volatility Position Sizing

May 15th, 2022
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4. inputs:monetary_risk(numericsimple), min_contr(numericsimple),max_contr(numericsimple),period_atr(numericsimple);
  5.  
  6. if AvgTrueRange(period_atr)<> 0 then begin
  7.     Value1= monetary_risk / (AvgTrueRange(period_atr) * bigpointvalue);
  8.     if value1 > max_contr then value2 = max_contr else value2 = value1;
  9.     if value2 < min_contr then value3 = min_contr else value3 = value2;
  10.  
  11. end;
  12.  
  13. Volatility_PS = value3;
  14.  
  15. -------------------------------------------------------------------
  16.  
  17. input: VPS(0), stop_loss(400), Risk(200);
  18.  
  19. # c significa "close"
  20. if VPS = 0 then begin
  21.     buy next bar at c + 1 * truerange stop;
  22.     setstopposition;
  23.     set stoploss(stop_loss);
  24. and;
  25.  
  26. if VPS = 1 then begin
  27.     buy Volatility_PS(Risk, 1, 10000000, 3) shares next bar at c + 1 * truerange stop;
  28.     setstopposition;
  29.     set stoploss(stop_loss);
  30.  
  31. and;
  32.  
  33. setexitonclose;
  34.  
  35. -------------------------------------------------------------------
  36.  
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement