Description
⋅ 前回、表示させた残高は「決済済みだけの残高」でした。
今回は「未決済(取引中)の損益も含めた残高」を表示させます。
(取引会社によって各社の表現が異なるので難しいのですが、、英語だと「account value」とされる項目です)
TradingViewでは、この資金量に応じて取引量を調整するようなロジックを組むこともできます。
=====
//@version=4
strategy( "MovingAvg2Line Cross" )
fastLength = input( 9 )
slowLength = input( 18 )
price = close
balance = strategy.initial_capital + strategy.netprofit
// ここで未決済を含む残高を算出
accountValue = balance + strategy.openprofit
mafast = sma( price ,fastLength )
maslow = sma( price ,slowLength )
if ( crossover( mafast ,maslow ) )
strategy.entry( "MA2CrossLE" ,strategy.long ,comment="MA2CrossLE" )
if ( crossunder( mafast, maslow ) )
strategy.entry( "MA2CrossSE" ,strategy.short ,comment="MA2CrossSE" )
plot( strategy.initial_capital )
plot( balance )
// 描画する
plot( accountValue ,color=color.red)
===== Comment
⋅ strategy.equity
も用意されています
strategy.initial_capital + strategy.netprofit + strategy.openprofit
Comment
⋅