简体   繁体   English

被盈亏所迷惑

[英]Confused by profit and loss

My strategy is for cryptocurrencies and I used to have these orders until now.我的策略是加密货币,直到现在我一直有这些订单。 I wanted to add profit target and stop loss, which means I have to use strategy.exit .我想添加利润目标和止损,这意味着我必须使用strategy.exit

strategy.entry("Buy", strategy.long, when = buyCondition)
strategy.close("Buy", when = sellCondition)

How are the profit and loss calculated?盈亏如何计算? All I want is buy price + custom %.我想要的只是购买价格+自定义百分比。 In other words, profit = buy price * (1 + (5 / 100)) .换句话说, profit = buy price * (1 + (5 / 100)) Same for stop loss, loss = buy price * (1 - (5 / 100)) .止损相同, loss = buy price * (1 - (5 / 100)) Or simply to calculate it based on close + syminfo.mintick or whatever that way was.或者只是根据close + syminfo.mintick或其他任何方式来计算它。 I just don't want numbers like 55000, look below.我只是不想要像 55000 这样的数字,请看下面。

strategy.exit("Custom sell", "Buy", profit = 55000)

code it like this: (in this example TP and SL are set to 5% each First you set up these lines:像这样编码:(在这个例子中,TP 和 SL 分别设置为 5% 首先你设置这些行:

// Stop Loss settings
StopLossPercent = input(5, title="Stop Loss", minval=0.01, step=0.5)
StopLoss = (close * (StopLossPercent / 100)) / syminfo.mintick

// Take Profit settings
TakeProfitPercent = input(5, title=" Take Profit", minval=0.01, step=0.5)
TakeProfit = (close * (TakeProfitPercent / 100)) / syminfo.mintick

Then for your strategy, you write this line below your strategy.entry然后对于你的策略,你在你的 strategy.entry 下写下这一行

strategy.exit("Stop Loss or Take Profit", loss = StopLoss, profit = TakeProfit)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM