Closed Avyyys closed 11 months ago
As an example, even if the step size is 50, it goes through each number separately. I noticed that it works fine for small numbers like "0.1" but for integers like "2", "5" or "10" it doesn't work anymore.
Thanks for raising the issue @Avyyys ,
Could you please share the sample publicly available TradingView Strategy with the exact 'start' 'end' parameters that you are running? So that I can reproduce the issue on my side.
Once you share it here, I will share the details regarding the issue.
This is not the same code as in the picture, but with this strategy I have had the same problem. Often, Optipie also calculates quite a lot of extra values for some reason and sometimes it has finished earlier than it should and also made an incomplete report.
In this code, I have had 2 parameters open, the values of the first parameter are 5 - 30 - 2 and the values of the second parameter are 50 - 250 - 10. Once I tried to add two more parameters, both of which had values of 1 - 6 - 1, but then it went completely messed and kept calculating extra values.
//@version=5 strategy(title="Double MA Strategy", shorttitle="DMA", overlay=true)
// Input for the lengths of two MAs len1 = input.int(9, minval=1, title="Length1") len2 = input.int(80, minval=1, title="Length2")
// Function to calculate different types of MAs ma(source, length, type) => switch type 1 => ta.sma(source, length) // SMA 2 => ta.ema(source, length) // EMA 3 => ta.wma(source, length) // WMA 4 => ta.vwma(source, length) // VWMA 5 => ta.rma(source, length) // SMMA 6 => ta.hma(source, length) // HMA
// Input for the types of two MAs type1 = input.int(title = "Type1", defval = 2, minval = 1, maxval = 6) // Default is EMA type2 = input.int(title = "Type2", defval = 2, minval = 1, maxval = 6) // Default is EMA
// Calculation of two MAs ma1 = ma(close, len1, type1) ma2 = ma(close, len2, type2)
// Plotting two MAs plot(ma1, title="MA1", color=color.blue) plot(ma2, title="MA2", color=color.red)
// Conditions for entry and exit signals buySignal = ta.crossover(ma1, ma2) sellSignal = ta.crossunder(ma1, ma2)
// Using strategy.entry and strategy.close for signals if (buySignal) strategy.entry("Buy", strategy.long) if (sellSignal) strategy.entry("Sell", strategy.short)
// Closing positions strategy.close("Close Long Position", when = sellSignal) strategy.close("Close Short Position", when = buySignal)
Hey @Avyyys
I have just checked that out and problem is that your OptiPie Step Size
should always match Pinescript Step Size
for the given input 'X'.
I have set 'step size' values explicitly for the first 2 inputs like this:
// Input for the lengths of two MAs
len1 = input.int(9, minval=1, title="Length1", step = 2)
len2 = input.int(80, minval=1, title="Length2", step = 10)
To match the step sizes which you set for OptiPie.
You can find the sample optimization report for this strategy, for BTCUSD
Please let me know if you have further questions.
Apparently that is a quite common issue that has been raised here multiple times so that to mitigate this problem I will add this solution to FAQs
I have had problems with step size. When I have more than one parameter, for some reason I can only get the step size of the first parameter to work, but not the step size of the second parameter. Even in the first parameter it only works if I add number like "2.0", but without ".0" it doesn't work at all. However, this solution no longer applies to the second parameter, I've tried everything, but I can't get it to work in another parameter at all. It always counts every number that is between the "start" and "end". I have also tried with another browser, but it had no effect.