简体   繁体   English

退出 position 松脚本

[英]Exit position Pine Script

How can I exit or close a position on a specific time of exchange in Pine Script.如何在 Pine Script 中的特定交换时间退出或关闭 position。 Example I have long position and want to close it on or before 1500 hrs as per Indian Time Zone.示例我有很长的 position 并希望根据印度时区在 1500 小时或之前关闭它。 Please help?请帮忙?

You can use the time() function for that.您可以为此使用time() function。

Here is an example where it marks candles between 1200 and 1500. It shouldn't be difficult to adapt according to your needs.这是一个示例,它在 1200 和 1500 之间标记蜡烛。根据您的需要进行调整应该不难。

//@version=5
indicator("My Script", overlay=true)

timeAllowed = input.session("1200-1500", "Allowed hours")

// Check to see if we are in allowed hours using session info on all 7 days of the week.
timeIsAllowed = time(timeframe.period, timeAllowed + ":1234567")

plotchar(timeIsAllowed, size=size.small)

在此处输入图像描述

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

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