在Pine脚本中,当我清楚地看到图表上的利润时,我的策略净利润是什么?

发布于 2025-01-24 05:27:52 字数 4307 浏览 2 评论 0原文

我正在实验长位置的简单策略,以下是结果(或多或少的43个利润小费):

“在此处输入图像说明”

这是我的策略的参数:

//@version=5
strategy(title="My strategy",
calc_on_every_tick=true,
overlay=true,
max_labels_count=500,
initial_capital=1000,
default_qty_value=20,
currency='USD',
process_orders_on_close=true,
commission_type='percent',
commission_value=0.075,
default_qty_type=strategy.cash,
calc_on_order_fills=true)

我也试图崛起 prinity_capital default_qty_value ,但净利润仍然很低。

我想念什么吗?

谢谢

ps :如果要测试,这是整个策略的代码

//@version=5
strategy(title="STRAT MANU 1", calc_on_every_tick=true, overlay=true, max_labels_count=500, initial_capital=1000, default_qty_value=20, currency='USD', process_orders_on_close=true, commission_type='percent', commission_value=0.075, default_qty_type=strategy.cash, calc_on_order_fills=true)




///////////////////////////
// FONCTIONS
///////////////////////////
Entering(entry_cond) =>
    result = false
    if entry_cond and strategy.opentrades > 0 == false
        result := true
    result


print(txt) =>
    label.new(bar_index, open, txt, yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)


GetPipSize() =>
    syminfo.mintick * (syminfo.type == "forex" ? 10 : 1)



///////////////////////////
// CONSTANTES
///////////////////////////

GROUP_INDICATEURS = "Indicateurs"
GROUP_MACD="MACD"
GROUP_HA="Heikin Ashi"
GROUP_RSI="RSI"
GROUP_CCI="CCI"
GROUP_RANGE = "Range and debugging"
GROUP_VA_RSI = "Variables d'ajustement RSI"
GROUP_VA_CCI = "Variables d'ajustement CCI"

// variable qui determine si la bougie fait partie du "range" pour le debuggage

timeAndDateInputBefore = input.time(timestamp("21 Apr 2022 16:00 +0300"), "Date départ")
timeAndDateInputAfter = input.time(timestamp("25 Apr 2022 22:00 +0300"), "Date arrivée")
bool barIsLater = time > timeAndDateInputBefore and time < timeAndDateInputAfter



///////////////////////////
// VARIABLES
///////////////////////////


var float stop_loss = na
var float take_profit = na




///////////////////////////
// INDICATEURS
///////////////////////////

        
// Heikin Ashi
haHandle=ticker.heikinashi(syminfo.tickerid)
haOpen=request.security(haHandle,timeframe.period,open)
haClose=request.security(haHandle,timeframe.period,close)
haLow=request.security(haHandle,timeframe.period,low)
haHigh=request.security(haHandle,timeframe.period,high)
haDeltaAbs=haClose-haClose[1] // diff abs entre les deux derniers close
//haDeltaRel=haDeltaAbs/(haClose[1]*100)  //

haDeltaRel = haClose/haClose[1]




// RSI
len = 14
//input(title="RSI Period", minval=1, defval=14)
src = close
//input(title="RSI Source", defval=close)
lbR = 5
//input(title="Pivot Lookback Right", defval=5)
lbL = 5
//input(title="Pivot Lookback Left", defval=5)
rangeUpper = 60
//input(title="Max of Lookback Range", defval=60)
rangeLower = 5
//input(title="Min of Lookback Range", defval=5)
plotBull = input.bool(title="Plot Bullish", defval=true)
plotHiddenBull = input.bool(title="Plot Hidden Bullish", defval=true)
plotBear = input.bool(title="Plot Bearish", defval=true)
plotHiddenBear = input.bool(title="Plot Hidden Bearish", defval=true)
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
osc = ta.rsi(src, len)

bool rsi_crossed = ta.barssince(ta.crossover(osc, 50)) < 1





// Trade Entry
bool haEntryCondition = haDeltaRel > 1 and haClose > haOpen and rsi_crossed and haOpen == haLow

bool red_ha =  haOpen > haClose



// Trade exit
Exit_cond = strategy.opentrades > 0 and ( close <= stop_loss or ( close >= take_profit and red_ha ) )



if barIsLater
    strategy.entry("my trade ", strategy.long, when = haEntryCondition and not haEntryCondition[1])
    strategy.close("my trade ", when = Exit_cond)


// MAJ TP SL

if Entering(haEntryCondition and rsi_crossed and not haEntryCondition[1])
    stop_loss := close - GetPipSize() * 10
    take_profit := close + GetPipSize() * 20

I am experimenting a simple strategy for long positions, here are the results (more or less 43 pips of profits):

enter image description here

Here are the parameters of my strategy:

//@version=5
strategy(title="My strategy",
calc_on_every_tick=true,
overlay=true,
max_labels_count=500,
initial_capital=1000,
default_qty_value=20,
currency='USD',
process_orders_on_close=true,
commission_type='percent',
commission_value=0.075,
default_qty_type=strategy.cash,
calc_on_order_fills=true)

I have also tried to rise initial_capital and default_qty_value but still very low net profit.

Am I missing something ?

Thanks

p.s: here is the code of the entire strategy if you want to test it

//@version=5
strategy(title="STRAT MANU 1", calc_on_every_tick=true, overlay=true, max_labels_count=500, initial_capital=1000, default_qty_value=20, currency='USD', process_orders_on_close=true, commission_type='percent', commission_value=0.075, default_qty_type=strategy.cash, calc_on_order_fills=true)




///////////////////////////
// FONCTIONS
///////////////////////////
Entering(entry_cond) =>
    result = false
    if entry_cond and strategy.opentrades > 0 == false
        result := true
    result


print(txt) =>
    label.new(bar_index, open, txt, yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)


GetPipSize() =>
    syminfo.mintick * (syminfo.type == "forex" ? 10 : 1)



///////////////////////////
// CONSTANTES
///////////////////////////

GROUP_INDICATEURS = "Indicateurs"
GROUP_MACD="MACD"
GROUP_HA="Heikin Ashi"
GROUP_RSI="RSI"
GROUP_CCI="CCI"
GROUP_RANGE = "Range and debugging"
GROUP_VA_RSI = "Variables d'ajustement RSI"
GROUP_VA_CCI = "Variables d'ajustement CCI"

// variable qui determine si la bougie fait partie du "range" pour le debuggage

timeAndDateInputBefore = input.time(timestamp("21 Apr 2022 16:00 +0300"), "Date départ")
timeAndDateInputAfter = input.time(timestamp("25 Apr 2022 22:00 +0300"), "Date arrivée")
bool barIsLater = time > timeAndDateInputBefore and time < timeAndDateInputAfter



///////////////////////////
// VARIABLES
///////////////////////////


var float stop_loss = na
var float take_profit = na




///////////////////////////
// INDICATEURS
///////////////////////////

        
// Heikin Ashi
haHandle=ticker.heikinashi(syminfo.tickerid)
haOpen=request.security(haHandle,timeframe.period,open)
haClose=request.security(haHandle,timeframe.period,close)
haLow=request.security(haHandle,timeframe.period,low)
haHigh=request.security(haHandle,timeframe.period,high)
haDeltaAbs=haClose-haClose[1] // diff abs entre les deux derniers close
//haDeltaRel=haDeltaAbs/(haClose[1]*100)  //

haDeltaRel = haClose/haClose[1]




// RSI
len = 14
//input(title="RSI Period", minval=1, defval=14)
src = close
//input(title="RSI Source", defval=close)
lbR = 5
//input(title="Pivot Lookback Right", defval=5)
lbL = 5
//input(title="Pivot Lookback Left", defval=5)
rangeUpper = 60
//input(title="Max of Lookback Range", defval=60)
rangeLower = 5
//input(title="Min of Lookback Range", defval=5)
plotBull = input.bool(title="Plot Bullish", defval=true)
plotHiddenBull = input.bool(title="Plot Hidden Bullish", defval=true)
plotBear = input.bool(title="Plot Bearish", defval=true)
plotHiddenBear = input.bool(title="Plot Hidden Bearish", defval=true)
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
osc = ta.rsi(src, len)

bool rsi_crossed = ta.barssince(ta.crossover(osc, 50)) < 1





// Trade Entry
bool haEntryCondition = haDeltaRel > 1 and haClose > haOpen and rsi_crossed and haOpen == haLow

bool red_ha =  haOpen > haClose



// Trade exit
Exit_cond = strategy.opentrades > 0 and ( close <= stop_loss or ( close >= take_profit and red_ha ) )



if barIsLater
    strategy.entry("my trade ", strategy.long, when = haEntryCondition and not haEntryCondition[1])
    strategy.close("my trade ", when = Exit_cond)


// MAJ TP SL

if Entering(haEntryCondition and rsi_crossed and not haEntryCondition[1])
    stop_loss := close - GetPipSize() * 10
    take_profit := close + GetPipSize() * 20

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文