Optimization variables, how to define?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #106127 quote
    soulintact
    Participant
    Senior

    Good evening!

    I tried to optimize different bull variables of HeikinAshi, but I am obviously doing it wrong. My logic was to define each indicator with a number; 1016-1020 and then labelling them as aa-ff in the optimization tool. Thanks in advance!

    //Definitions of different BullHeikinAshi
    BullishHaramiCross=1016
    BullishCounterAttack=1017
    BullishBreakaway=1018
    GapUp=1018
    InvertedHammer=1019
    TweezersTop=1020
    
    //Bullish Signal Heikin Ashi
    
    BullishBreakaway=(body[4]<0 and body[3]<0 and body>0 and open[3]<close[4] and close[2]<close[3] and close[1]<close[2] and longcandle and close<close[4] and close>open[3]) and TrendDown[5]
    
    BullishCounterAttack=(body[1]<0 and longcandle[1] and body>0 and longcandle and close<=close[1]) and TrendDown[2]
    
    BullishHaramiCross=(body[1]<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1] and ratio<0.3 and range<0.3*range[1]) and TrendDown[2]
    
    GapUp=(low>high[1])
    
    InvertedHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>2*abody and shadowbottom<0.3*abody)and TrendDown[2]
    
    TweezersTop=(body[1]>0 AND longcandle[1] AND body<=0 AND high=high[1]) and TrendUp[2]
    
    BullHeikinAshi=aa or bb or cc or dd or ee or ff
    variable-optimization.png variable-optimization.png
    #106129 quote
    GraHal
    Participant
    Master

    Why didn’t you do below?

    //Definitions of different BullHeikinAshi
    BullishHaramiCross=aa
    BullishCounterAttack=bb
    BullishBreakaway=cc
    GapUp=dd
    InvertedHammer=ee
    TweezersTop=ff
    soulintact thanked this post
    #106132 quote
    soulintact
    Participant
    Senior

    Thanks GraHal, but the optimization is done in numbers. Doing the optimization could exclude several BullHeikinAshi as aa-ff could end up in just being one or two of the variables.

    Optimization example: aa=1017, bb=1017, cc=1018, dd=1018, ee=1018, ff=1017.

    Conclusion: only use BullishCounterAttack (1017) and BullishBreakaway (1018) in the statement.

    definition-in-numbers.png definition-in-numbers.png
    #106134 quote
    GraHal
    Participant
    Master

    So with BullishHaramiCross=aa then optimised result could be ….

    BullishHaramiCross = 1016
    or
    BullishHaramiCross = 1017
    or
    BullishHaramiCross = 1018
    or
    BullishHaramiCross = 1019
    or
    BullishHaramiCross = 1020

    #106135 quote
    soulintact
    Participant
    Senior

    Thanks GraHal, but I am sorry, I do not see how that would help me sorting out possible variables?

    #106137 quote
    GraHal
    Participant
    Master

    I’ve just seen below

    BullHeikinAshi=aa or bb or cc or dd or ee or ff

    So I’d have coded

    BHC = BullishHaramiCross=aa
    BCA = BullishCounterAttack=bb
    BB = BullishBreakaway=cc
    GU = GapUp=dd
    IH = InvertedHammer=ee
    TT= TweezersTop=ff
    
    BullHeikinAshi = BHC or BCA or BB or GU or IH or TT
    
    

    Maybe I’m reading your problem all wrong?? 🙂  Vonasi or Roberto … help?? 🙂

    #106138 quote
    GraHal
    Participant
    Master

    Now I look at and have read all your code I don’t see how – for example – you can optimise below in the way I suggest, apologies! 🙂

    BullishHaramiCross=(body[1]<0 and longcandle[1] and bodybottom>bodybottom[1]

     

    Maybe best if Vonaso or Roberto delete my posts and I stop watching TV at the same time I make comments on here!? 🙂

    #106139 quote
    soulintact
    Participant
    Senior

    No worries GraHal, I am thankful that you are responding so quickly on a Sunday evening when you should watch  TV 🙂

    My statement is probably so absurd that it was difficult to grasp. Anyhow, let’s see how it evolves tomorrow. TV suggestions: Vis a vis on Netflix and Quarry on HBO 🙂
    Not to forget Toc Toc on Netflix.

    GraHal thanked this post
    #106174 quote
    Nicolas
    Keymaster
    Master

    You could test this way of adding the boolean condition in the same variable:

    if aa = 1016 then 
     BullHeikinAshi=bullheikinashi and BullishHaramiCross
    elsif aa = 1017 then  
     BullHeikinAshi=bullheikinashi and BullishCounterAttack
    elsif aa = 1018 then  
     // .. and so on ..

    Do the same for bb,cc,…

    (not tested)

    soulintact thanked this post
    #106175 quote
    soulintact
    Participant
    Senior

    Good morning Nicolas and thank you very much.

    Your suggestion seems logical and I will try that approach. After testing I will confirm and include the partial code, THANKS!

    #106224 quote
    soulintact
    Participant
    Senior

    Dear Nicolas, I just want to confirm that your suggestion worked very well. I enclose the code:

    //Definitions of BullHeikinAshi
    if aa = 1016 then
    aaa=BullishHaramiCross
    elsif aa = 1017 then
    aaa=BullishCounterAttack
    elsif aa = 1018 then
    aaa=BullishBreakaway
    elsif aa = 1019 then
    aaa=GapUp
    elsif aa = 1020 then
    aaa=InvertedHammer
    
    
    elsif aa = 1021 then
    aaa=TweezersTop
    
    elsif bb = 1016 then
    bbb=BullishHaramiCross
    elsif bb = 1017 then
    bbb=BullishCounterAttack
    elsif bb = 1018 then
    bbb=BullishBreakaway
    elsif bb = 1019 then
    bbb=GapUp
    elsif bb = 1020 then
    bbb=InvertedHammer
    elsif bb = 1021 then
    bbb=TweezersTop
    
    elsif cc = 1016 then
    ccc=BullishHaramiCross
    elsif cc = 1017 then
    ccc=BullishCounterAttack
    elsif cc = 1018 then
    ccc=BullishBreakaway
    elsif cc = 1019 then
    ccc=GapUp
    elsif cc = 1020 then
    ccc=InvertedHammer
    elsif cc = 1021 then
    ccc=TweezersTop
    
    elsif dd = 1016 then
    ddd=BullishHaramiCross
    elsif dd = 1017 then
    ddd=BullishCounterAttack
    elsif dd = 1018 then
    ddd=BullishBreakaway
    elsif dd = 1019 then
    ddd=GapUp
    elsif dd = 1020 then
    ddd=InvertedHammer
    elsif dd = 1021 then
    ddd=TweezersTop
    
    elsif ee = 1016 then
    eee=BullishHaramiCross
    elsif ee = 1017 then
    eee=BullishCounterAttack
    elsif ee = 1018 then
    eee=BullishBreakaway
    elsif ee = 1019 then
    eee=GapUp
    elsif ee = 1020 then
    eee=InvertedHammer
    elsif ee = 1021 then
    eee=TweezersTop
    
    endif
    
    BullHeikinAshi=aaa or bbb or ccc or ddd or eee

    Having 5 alternatives was a bit too many. 3 seems to be well enough. By the optimization, I can filter out what factors that likely work best within a specific time frame and stock.

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

Optimization variables, how to define?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
soulintact @soulintact Participant
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by soulintact
6 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/01/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...