Draw Signal Arrow and Code Correction

Forums ProRealTime English forum ProBuilder support Draw Signal Arrow and Code Correction

Viewing 14 posts - 1 through 14 (of 14 total)
  • #227500

    Hi, Everyone.. !

    I am learning to prepare code to create buy and sell signal based on simple moving average. This is just trial so using it to learn rather trade, however it seems I am missing something in the code so I would appreciate any help. Before Posting I watched this video ( https://www.youtube.com/watch?v=NL8GJoYVT00&t=85s ) to learn and followed it but it seems I am using v12 and what was taught in the video was older version.

    See below my code and image for the output I get. In the code I have defined variable for Short (i.e 5) and Long (i.e. 15).

    Instead of arrow i used dott as explained the youtube video however I would appreciate if you some guide on how to draw arrow.  I wanted to show up arrow in green colour every time MA5 crosses over MA15. However as you can see in the image the code keep printing the blue dots not just when MA5 cross over MA15 but it continue to have dot all the way then turn it into red colour.

    Now, I wanted to show red arrow when MA5 crosses below MA15 with red colour (i used dot again) but it isn’t working.

    basically i can see red dot when MA5 is above MA15 and blue when MA5 is below MA15, which isn’t what i asked in the signal a well.

    If there is another YouTube channel where i can have a look this type of examples but with never version of PRT then please suggest.

     

    Thanks in advance for the help.

     

    Regards,

    #227511

    Hi,

    To display arrows you need to use graphic commands DRAWARROWUP / DOWN, that’s independant from variables (here “signal” formatted as dots) returned by the final line “return”. Here is amended code suggestion for arrows at cross over (assuming they are wanted only at cross over):

     

     

     

    1 user thanked author for this post.
    #227522

    Thank you so much. It worked as I expected.

    Now, when I compared your code with mine I can see you have not used “Signal” in your code and still there was signal came out as an arrow which i guess something to learn for me.

    I slightly modified the code as below and I keep getting downward arrow multiple times instead of once. I know program is doing what I wrote so it’s not the issue with the program but instead it is my limitation on what other logic i can use so that only time downward arrow appears if there was upward arrow before ! (see attached image on what I get when i put below code in RPT).

     

     

    #227596

    Yes, two ways to draw something in probuilder, one way is to say which variables in your code you want to see drawn for each candle in the final “return” line of the indicator, the other way is to use some “graphical” instructions which you can find in current site in this section:

    https://www.prorealcode.com/documentation/category/graphical/

    If you want to only see the latest 2 up and down crossover, and real time replacement of them without relaunching the indicator, you can adapt slightly the code made in this post:

    https://www.prorealcode.com/topic/draw-segments-around-signal-bar/#post-227251

    in this way:

    DEFPARAM DRAWONLASTBARONLY = TRUE

    //define parameters

    //short=5
    //long=15

    MAShort = Average[Short](close)
    MALong = Average[Long](close)

    If MAShort CROSSES OVER MALong THEN
    memob1=barindex
    memolow=low
    ELSif MAShort CROSSES UNDER MALong THEN
    memob2=barindex
    memohigh=high
    ENDIF

    DRAWARROWUP(memob1, memolow-2*pipsize) coloured(0,255,0)
    DRAWARROWDOWN(memob2, memohigh+2*pipsize) coloured(255,0,0)

    RETURN

    1 user thanked author for this post.
    #227613

    Thank you. The issue still remains, as you can see in attached image, signal number 6 and 9 shouldn’t have appeared because what I was looking for is that the only time red signal appears if there was green signal earlier. all other signal in the image are correctly appearing as expected. The also reduced number of red signals but it didn’t eliminate the error we need to remove.

    we need a logic that trigger the drawdown arrow only if there was up arrow before ! hope image will help to understand what i meant. As i don’t need sell signal at 6 or 9 as there was no buy signal earlier to this two bar..!

    #227615

    try with this:

     

    1 user thanked author for this post.
    #227618

    Thank you so much. Your amendment worked. I notice in your code you are using “LngArrowOK” and “SrtArrowOK” , but are they name you used or something already prebuilt function in the PRT?

    Also, you used a very smart logic where you are using this two in a sequence such that arrow only appears if up or down arrow was previously appeared and hence removing issue i faced earlier. Very smart and intelligent logic!

    However, the variable distance is creating issue as having it set to 10 means Arrow are not on the chart but they fly up or down and I need to zoom in too much to see them on some of the stock while it appears correctly on others. I reduced value from 10 to 0.1 and it worked on majority but still not correctly set on few stocks. so is there a way to have them appear on the candle up or down side ?

    #227620

    Thank you so much. Your amendment worked. I notice in your code you are using “LngArrowOK” and “SrtArrowOK” , but are they name you used or something already prebuilt function in the PRT?

    No, they are just variable names. You can change their names to whatever you want. Note that most of the black texts are variables and the blue and green texts are programming language commands; and the quantities are in magenta.

    Also, you used a very smart logic where you are using this two in a sequence such that arrow only appears if up or down arrow was previously appeared and hence removing issue i faced earlier. Very smart and intelligent logic!

    Congratulations, you have got the logic perfectly.

    However, the variable distance is creating issue as having it set to 10 means Arrow are not on the chart but they fly up or down and I need to zoom in too much to see them on some of the stock while it appears correctly on others. I reduced value from 10 to 0.1 and it worked on majority but still not correctly set on few stocks.

    I decided to create a variable called distance in the settings section so that you can change the distance of the arrow depending on the time period or the financial instrument to which you apply the indicator.
    It is also more agile for you to replace the graphic command of the arrows with the graphic command that paints vertical lines, assigning a different color to each type of entry. Look this new code:

    so is there a way to have them appear on the candle up or down side ?

    I don’t know if I’m understanding what you’re saying correctly because “distance” variable is used to decide how far each type of arrow is located (some up and others down, taking the candle close as a starting point).

    1 user thanked author for this post.
    #227621

    I understand that the distance variable will allow manually adjusting location but if you want to go through various stocks saved in your list then it will be difficult to use it. As per the image below, you can see that for large and even for mid cap prie stock the arrow literally not visible as they all appear at the bottom of the page.  only for the small cap arrow appears just above or below the candle and some location inside the candle.

    So what I was looking for is to have upward arrow to be placed at the bottom of the candle and downward arrow at the top of the candle as default as per attached second image you will see them in pink circles.

    I checked code provided above by JC_Bwyan and used his line ” low2*pipsize ” but removed numerical number so it is now “low*pipsize” and it gives arrow on top & bottom of the candle for small caps but not for large caps or mid caps. 

     

    #227656

    Hi!

    I use ATR and it works quite good, at least for me 🙂

     

    #227662

    Hi there !!
    What Iván has explained is a quite practical solution for your case (I would replace the value that he has written “o.1” with the text “distance”, which is the distance variable that we have previously mentioned, to be able to control the adjustment of the distance according to your need).
    Also try my last code, the one that uses vertical lines.

    1 user thanked author for this post.
    #227945

    use this one, the best one

    #228124

    I used -0.1 & +0.1 as per your code and it works on large cap but doesn’t work on penny stocks.

     

    could you check on your system if you can see arrow correctly for the stock code ” TTI ” it’s Australian stock Traffic technology? and let me know if it works in your system?

     

     

    #228125

    Also, how can i change colour of the arrow from RED and GREEN that I get based on above code? is there a list of various colour against the code that we need to use?

Viewing 14 posts - 1 through 14 (of 14 total)

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