MTF code trouble.

Viewing 12 posts - 1 through 12 (of 12 total)
  • #197240

     

    Hi All,

    I am trying to code something simple indicator that shows the following on a Daily chart.

    Weekly signal if the average range of the last 4 weeks is less than the range of the last week. (This signal should be valid for the whole next week).

    Daily signal if the range of the last 5 days is less than the range of today.

    If both of those are true then I get my signal.

    The problem I am having is that although I have coded it several different ways I keep getting false readings when I put them together. I can put the weekly indicator on a weekly chart and it is correct but when I put it in combination with the daily signal on a daily chart it does not show correctly.

    What am I doing wrong?

     

     

     

    #197241

    In line 3 you need to remove [1] from the rightmost RANGE, as UpdateOnClose grants it’s always the LAST closed candle, not the current one.
    In line 12 the rightmost RANGE has no brackets and will refer to the current candle.

    1 user thanked author for this post.
    #197249

    Thank you Roberto,

    Now the only problem I have is the weekly signal doesn’t got from Monday to Friday, but goes from Friday to Thursday. How do I rectify that?
    Or maybe a better question is how would you code all this? I am new to this and trying to learn but I have a suspicion that my coding is not good 🙁

    #197318

    I am not experiencing that issue.

     

    #197319

    That’s odd. Here is a screenshot, the weekly indicator goes from Friday to Thursday. However I have fiddled with it and if I return Wsignal[1], then it goes correctly  from Monday to Friday. But I don’t understand why it is doing that??

    Sorry to be a pain but could you explain it to me.

    #197321

    As you can see from the attached pics, it works fine for me.

    Try contacting ProRealTime.

     

     

    #197325

    I get exactly that when I do it separately on daily and weekly charts like you have. the problem occurs when I put them together in one indicator.

    #197330

    Do you have free charts which are 1 bar behind? This might be source of your issue.

     

    #197334

    hi…   had a look at your code to see if I could  see any  problems other than your love of ‘brackets’!

    Couldn’t  see anything other than the ‘brackets’, and the differences of line 3 and it seemed to work for me.

    In trying to understand and verify it was correct I created an alternate version, while debugging, with line plots to see, when the range’s crossed over the average’s, the bar’s were in the right position. Also I wonder about using the stock average function, so I incorporated that in as well to compare with manual calculated version. This gave the added benefit of changing the average type to EMA and other’s. Then there were a few only things and then four hour’s later…

    By adding 4 identical indicators and using different setting for each, see pic panel labels, you can see whats happening and make a comparison. When lines cross and different average’s. One thing I did find interesting, is the 5 daily values for the average calculation required a value of ‘6’ in the average function to make them the same, not sure why yet.

    The variables in settings, ‘page’ switches between line/bar, ‘choice’ between manual/stock average calculation, ‘aveType’ set the type of average, ‘avetext’ turns on/off text for number type of ‘aveType’

    pic1

    Pic 1 shows price, and 2 sets of similar panels. The top 2 show the range/average range lines and the bars of the manual calculated SMA version while the bottom 2, are the same but using the Average function. Pic 2 is similar but the bottom 2 are set to ema.

    pic2

    The code file below is what I ended up with. When importing it should set the dynamic variable’s if not there listed at the top of the code. I’ve hard coded the colors and styles so it should look good out of the box, but there an alternate RETURN statement you can switch between if you want to set them in the indicator settings.

     

    1 user thanked author for this post.
    #197490

    No I don’t think so. It works fine when just using a single timeframe.

    #197492

    @druby Thank you.
    I thank you for your generosity with your time,(when I see your code, I understand my bracket addiction, (ha)*2)
    Your answer definitely falls into the category of being careful what you ask for .Just starting to code and it has taken me a couple of days just to begin understand it!

    1 user thanked author for this post.
    #197495

    Thanks a lot for your comments, your welcome.

    Just came across this in a code file I wrote, here’s the bit I wan’t to point out. Good reminder!

    The code help me understand ‘Round, Ceil, and ‘Floor’ commands and just posted else where, see link,.  Also stuff regarding anchoring text, when you get wound up at that stage.

    https://www.prorealcode.com/topic/affichage-ema-200-sur-ut-15-et-15-mn/

    Best regards

Viewing 12 posts - 1 through 12 (of 12 total)
Similar topics:

Create your free account now and post your request to benefit from the help of the community
Register or Login