When I use ChartData.CloseD() method to get the daily close price, I always get the value 0

So I want to extend a signal that uses two chart timeframes , one is lower timeframe and the other is daily timeframe. It's used for multi timeframe strategy.



Anyways, as we know if we use the ChartData.Close(1) method to get the previous bar close price, it will return the close price of the time frame selected in the builder, let's say in the builder I select the lower timeframe.


But as the block I want to develop is used in a multi timeframe strategy, I need the close price of the daily bar.


So I used the method ChartData.CloseD(1) to get the previous day close price. But unfortunately it doesn't return the previous day close price. It always return the value 0.
 Same thing for other daily price methods OpenD(), LowD() and HighD().




so this is just an example code, lets say we want to get a signal if yesterday close was bigger than two days ago close





package SQ.Blocks.Indicators.CandlePatterns; import SQ.Internal.ConditionBlock; import com.strategyquant.lib.*; import com.strategyquant.datalib.*; import com.strategyquant.tradinglib.*; @BuildingBlock(name="Example Patern", display="Example Patern before (#Shift#) bars", returnType = ReturnTypes.Boolean) @Help("Is triggered when Example Patern is formed") public class ExamplePatern extends ConditionBlock { @Parameter public ChartData Chart; @Parameter(defaultValue="1") public int Shift; //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ @Override public boolean OnBlockEvaluate() throws TradingException { double C = Chart.CloseD(Shift); double C1 = Chart.CloseD(Shift+1); if (C > C1) { return true; } return false; } }





the code above will not give any signal, it is because I used Chart.CloseD(), but if Instead I used Chart.Close() it will work correctly in the above code.


But again as I said before, for the block I'm trying to develop, it's used in multi timeframe strategy, so can't use Chart.Close() because it will give back the lower timeframe close price, this lower time frame is selected in the builder

Attachments
No attachments
  • Votes +1
  • Project Extending SQ
  • Type Bug
  • Status New
  • Priority Normal

History

SR
#1

SixtoRod

03.04.2021 05:56

Task created

SR
#2

SixtoRod

03.04.2021 06:04

Type changed from Indicator / Signal to Problem

SR
#3

SixtoRod

03.04.2021 10:29

Type changed from Problem to Bug

IH
#4

clonex / Ivan Hudec

03.04.2021 14:54
Use 131 last dev here it should be handled.
E
#5

Emmanuel

15.12.2021 19:42
Voted for this task.

Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please