Using 500 previous candles in a study

crypt0grapher

New member
Joined
Jul 19, 2023
Posts
3
Likes
0
Hey, could someone please assist me in clarifying the following?
Recently I built a simple strategy, The thing is that as an input it uses ATR for 500 previous periods.
The approach I’m using is pretty standard:
In the calculate() method, I’m getting series = ctx.getDataSeries() and then calling series.atr(index, c) where c is 500 or another (large) value from the input.

The script works out pretty fine in TradingView, although in MotiveWave I got no signals frpm it since it starts counting from the first visible candle and the chart fits more or less 400 of them (ironically) making the study useless.
If there are 200 candles they get some signals on the right side of the chart which I'm showing on the attached screenshot, where there’s “missing” data in the red box. The right side of the screen is fine - that's what I'd like to get for the whole chart - the study is working and the painting of the candles and places signals is just fine.

Here are my questions.
1. Just to confirm during the continuous feed from the market (the client uses CQG), is the situation the same, or when the feed is on and the chart “moves” so to speak, is the feed coming and the study will get those previous 500 bars for every new candle.
2. Please advise if there’s a way to configure this option to receive those 500 previous candles from the beginning.
3. If 2. is not possible, could someone clearly state this is an MW limitation but not I'm missing something?

I'm a Java developer working with trading systems for a living and loving to work on MW studies for my clients from time to time and this time the guy refuses to accept the job, so the answers to those questions would help me a lot irrespective of if they are positive or not.
Many thanks in advance!

Best,
Alex
 

Attachments

  • image.png
    image.png
    418 KB · Views: 14
Last edited:

igor.s

Well-known member
Joined
May 22, 2019
Posts
289
Likes
153
Not sure if it helps but you can try to call this method in the Study
...
public void setMinBars(int bars)
Sets the minimum number of bars required to display this study.
Parameters:bars - minimum number of bars
...

cheers
 

Spin

Well-known member
Joined
May 22, 2019
Posts
486
Likes
194
Welcome to the MW-coders-community, @crypt0grapher :D

@igor.s is -as ever so often- right :)

I go about it this way:
Java:
@Override
    public void onLoad(Defaults defaults) {

        debug("OnLoad");
        setMinBars(250);

    }

What also helps a lot is having your Study print a debug-statement with the index number of the first and last bars, just to be sure you have enough data to work on ;)
 

crypt0grapher

New member
Joined
Jul 19, 2023
Posts
3
Likes
0
Welcome to the MW-coders-community, @crypt0grapher :D

@igor.s is -as ever so often- right :)

I go about it this way:
Java:
@Override
    public void onLoad(Defaults defaults) {

        debug("OnLoad");
        setMinBars(250);

    }

What also helps a lot is having your Study print a debug-statement with the index number of the first and last bars, just to be sure you have enough data to work on ;)
Awesome! Thank you very much!
 

crypt0grapher

New member
Joined
Jul 19, 2023
Posts
3
Likes
0
Not sure if it helps but you can try to call this method in the Study
...
public void setMinBars(int bars)
Sets the minimum number of bars required to display this study.
Parameters:bars - minimum number of bars
...

cheers
Thank you!
 
Top