简体   繁体   中英

Enter the cost of the spread in the Pine Script strategies

Good morning,

I am trying to find a possibility to insert the spread as a fixed cost for each trade in my Pine Script strategies on Tradingview.

I give an example: I write a strategy on Pine script and execute it. Logically, the results will not be fully realistic, considering the costs of commissions and / or spreads (depending on the broker) and the slippage variable.

Although it is a variable element, in the strategy settings, I can enter a slippage value even higher than what I will actually have in most trades.

I can also enter a fixed commission value, if I choose a broker that charges fixed commissions.

I wish I could do the same thing for the spread, by entering a higher value than what I would find in most trades. For example in Eur / Usd, considering the spread of many brokers, I could enter a maximum value of 1.2 Pip (12 ticks). I could try to insert an even larger value to stress the strategy. By also inserting a high slippage (10 ticks for example), I would have results that are closer to reality. If the strategy works with these costs, it is very likely that it works in reality.

In PineScript, there is no method in the strategy settings to enter the spread and I have not found any help in the documents that Tradingview makes available for programming on Pine Script.

Is there a way to set a hypothetical spread in the strategies?

这个设置可以做同样的事情

The first one affects execution price for limit order. The second one (slippage) affects execution price for market and stop orders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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