Gann Swing – Show Bar

Optuma Forums Optuma Scripting Gann Swing – Show Bar

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #28519
    Jonathan
    • Topics: 38
    • Replies: 58
    • Posts: 96

    Hello Forum,

     

    I feel there is a real lack of scripts from the public on this forum and also on the internet when it comes to trading methods. I can search in every direction for a MetaTrader script, near impossible to find a Optuma Script.

    I am in the process of trying to get the script to work correctly, however it is having some small technical errors to what I am trying to achieve. I copied to script prebuilt into OPTUMA and then made a small change, however it still needs tweaking – but I am unsure which section it is!

     

    How to Enter a Trade on a Swing Chart

    When using Gann Swing Theory to buy a stock buy  on the presence of higher swing highs and higher swing lows, when price rises $0.01 above the previous swing high after confirmation of a higher swing low.

    //GANN SWING IS UP

    GS1 = GANNSWING(USEINSIDE=False, METHOD=Use Next Bar); SWINGUP() and

    //GANN SWING 1 is GREATER than Swing Start GS1
    (SWINGEND(GS1) > SWINGSTART(GS1,OFFSET=1)) AND

    //GANN SWING 2 is GREATER than Swing Low (2)
    ((SWINGEND(GS1,OFFSET=2) > SWINGSTART(GS1,OFFSET=2)) AND
    //SWING HIGH Breaks Above The High of Swing High (1)
    (HIGH() >= SWINGSTART(GS1,OFFSET=3)))

     

     

    There is defiantly mistakes with this script, However this is what I am trying to achieve – please see the image.

    • This topic was modified 4 years ago by Jonathan.
    #28567
    Matthew
    • Topics: 5
    • Replies: 421
    • Posts: 426

    Hi Jonathan,

    Thank you for your post.

    There are two main issues i can see in the script, the first is with SWINGUP().   It should be SWINGUP(GS1).

    Secondly, looking at your screen shot you are using Gann Swing Settings of Use Outside Bar however the script is set to Use Next Bar.  I’ve kept the adjusted scripts to Next Bar, but if you are comparing them to your chart you will need to update the Gann Swing Overlays settings.

    I believe the following scripts are what you are after…

     

    To Buy

     

    To Sell

     

    #28571
    Jonathan
    • Topics: 38
    • Replies: 58
    • Posts: 96

    Thank you for providing this script.

     

    However there appears to be an error in the code.

     

    I changed some code to >= (would > than 0.01c be a way to limit even highs?)

     

    Please see both images. The second image, contains changed code & also – Red box for where the script is finding invalid rules, and green where the script highlighted the rule correctly.

    • This reply was modified 4 years ago by Jonathan.
    #28611
    Matthew
    • Topics: 5
    • Replies: 421
    • Posts: 426

    The results in the red box appear to be due to the how normal High() data lists join to the Swing list when using High() >= SWINGSTART(), and where the criteria is placed in the script.

    The following modified scripts should provide the results you are after:

    Bull Script

    Bear script

     

    With your other question – (would > than 0.01c be a way to limit even highs?)

    I think we could replace High() >= SWINGSTART() with (High() – SWINGSTART(GS1,OFFSET=1) > 0.01)

    #28615
    Jonathan
    • Topics: 38
    • Replies: 58
    • Posts: 96

    Hey Matthew

     

    I think to get the script to be useful to other members who view this forum, we should work at perfecting the script.

    Either right now, the program is faulty or the script is faulty.

     

    I tried to modify different areas again without success, but here is my findings on a monthly chart.

    Did you use the show bar tool and test the script out of curiosity, Am I doing something completely wrong on my end?

     

    See image.

    #28643
    Jonathan
    • Topics: 38
    • Replies: 58
    • Posts: 96

    Hey,

     

    I am still working on perfecting the code.

     

    If anyone had input, feel free to add..

    • This reply was modified 4 years ago by Jonathan.
    #28651
    Darren
    • Topics: 66
    • Replies: 661
    • Posts: 727

    Hi Jonathan,

    Try these scripts for the Show Bar:

    Buy Signal

    GS1 = GANNSWING(METHOD=Use Next Bar);
    // Look for the downswing and its swing low is higher than the previous swing slow
    (SWINGEND(GS1) < SWINGSTART(GS1)) and (SWINGEND(GS1) > SWINGSTART(GS1, OFFSET=1)) and
    // And the current bar high is greater than the previous swing high
    (High() > SWINGEND(GS1, OFFSET=1)) and (Low() > SWINGEND(GS1))
    Sell Signal
     GS1 = GANNSWING(METHOD=Use Next Bar);
    // Look for the upswing and its swing high is lower than the previous swing high
    (SWINGEND(GS1) > SWINGSTART(GS1)) and (SWINGEND(GS1) < SWINGSTART(GS1, OFFSET=1)) and
    // And the current bar low is lower than the previous swing low
    (Low() < SWINGSTART(GS1, OFFSET=1)) and (High() < SWINGSTART(GS1))
    Note that the arrows will be applied to the bar where the swing is confirmed, as per the attached weekly chart of CBA.
    • This reply was modified 4 years ago by Darren.
    #28675
    Jonathan
    • Topics: 38
    • Replies: 58
    • Posts: 96

    Hey,
    Thanks Darren.

     

    Purely based on the rules, Optuma64bit/Market Analyst is not signalling all the possible buy signals that are valid.

    Green is missed buy signals & red is missed sell signals.

    I am obviously using a small sample of data here but I need to use this on a large scale scan of the top 100 stocks on a weekly basis.

    Also I have not had any luck using the NoRepeat function on this script. Essentially I just want it to ‘ShowBar’ the latest signal once activated.

    That is, show bar only once for each buy / sell signal. This way If pyramiding is activated the stock is not being bought 4 times in a month due to the show bar being displayed multiple times and the script being activated.

     

    Furthermore, I know that we are using the GannSwing function. However I would like to get the script to work for both gann rules and also DOW theory rules. Is the gannswing script function suitable?

    #28695
    Matthew
    • Topics: 5
    • Replies: 421
    • Posts: 426

    Hi Jonathan,

    Looking at the last screen image i think we need to split the script up further to fill in the missing signals.  I’ve tested the following and it seems to do the trick:

    Bull Signal

     

    Bear Signal

    Attached is how the above scripts display on my chart of CBA now.

    Once we have the core aspect of the script working, we can then look at adding No Repeats, etc.

     

    • This reply was modified 4 years ago by Mark Wass.
    #28755
    Jonathan
    • Topics: 38
    • Replies: 58
    • Posts: 96

    Hey,

     

    Thanks for this script. I am sure its much closer to the final product, however I am having a hard time implementing the script due to (&lt;=) placed into the script instead of < = > .. Is there a way to have the forum not display (&lt;=) and instead display the script correctly?

     

    I tried to modify it, however it is showing no results. I am under the impression that all the (&lt;=) actually equal < or >=

     

    • This reply was modified 4 years ago by Jonathan.
    #28786
    Mark
    • Topics: 4
    • Replies: 135
    • Posts: 139

    Hi Jonathan

    Thanks for your last post regarding html coding of the < and > symbols. I’ve made a change to the forum that should prevent the code viewer from translating < and > to &lt; and &gt;

    For your reference if you want your code to display like Matthew’s simply wrap your code in <pre>your_code_here</pre> tags. This can be done by swapping to the “Text” view tab and then select your code segment (highlight it) then click the “pre” button.

    Hope this helps.

    Regards

    Mark

    • This reply was modified 4 years ago by Mark Wass.
    #28967
    Panu
    • Topics: 0
    • Replies: 1
    • Posts: 1

    Hi all,

    These are very useful scripts, thank you. I’m using them successfully in the Back Tester on a “1 week” data timeframe.

    Matthew, is the following a valid addition to your scripts? I’m trying to confirm that the monthly Gann Swing is also up/down before a weekly buy/sell is triggered.

    (Matthew’s_bull_script) And GANNSWING(MONTH(), METHOD=Use Next Bar) IsUp

    (Matthew’s_bear_script) And GANNSWING(MONTH(), METHOD=Use Next Bar) IsDown

    #28999
    Darren
    • Topics: 66
    • Replies: 661
    • Posts: 727

    Hi Panu,

    Yes that should work.

    #30031
    Ryan
    • Topics: 1
    • Replies: 5
    • Posts: 6

    Hi All,

    Just wondering if anyone has had any success building on the above script to return an entry/exit price based on the previous peak (or trough for a bear market)?

    In theory, all I’m trying to do at this stage is have the script return the price of the previous peak. Running the below script returns what appears to be some form of null value (breaks in the plot). Breaking down the script shows that the individual components of the code execute as expected which is why I’m thinking that it may have something to do with the assembly.

    • This reply was modified 4 years ago by Ryan.
    #36623
    Darren
    • Topics: 66
    • Replies: 661
    • Posts: 727

    Hi Ryan,

    If you just want the value of the swings displayed on the chart then you can enable the labels option:

    Capture

    To display the values in a watchlist for example will require a script using offsets to look at the previous swing high and swing low. The value of the offset count will depend if the current swing is up or down. Use the following to get the previous swing high for a 2 bar count:

    // get the swings

    gs1 = GANNSWING(SWINGCOUNT=2, METHOD=Use Next Bar);

    // get the starting values of the swings

    s1 = SWINGSTART(gs1);

    // get the direction of the swing

    d1 = SWINGUP(gs1);

    //if the current swing is up get the previous swingstart for the peak or current swingstart if down

    IF(d1==1,s1[1],s1)

    In this example AMZN is in a downswing so the previous high was the swingstart S1 at 910.50, whereas CAKE is in an upswing so we need to look at the previous swingstart S1[1] – where the number in the [] is the number of offsets – to show 65.09:

    Capture

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest