Measure MA on the next bar

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #210006 quote
    miric94
    Participant
    New

    Hello!

    Still very new here and learning so much.

     

    I’ve been trying to find a solution to this as I am pretty sure it’s rather simple but I just can’t.

    I want to short when high is >= MyLine and MA1 =< MyLine which is working fine.

    But I don’t want to short if price keeps rising or MA goes above MyLine. (see attached)

     

    I feel that I should measure MA Increase from lastbar to current  or just crossing but not sure how to do it.

    BarIndex?

    Does anyone have any idea what to do?

     

    Marcus

    screendump.jpg screendump.jpg
    #210011 quote
    robertogozzi
    Moderator
    Master

    Instead of checking the two conditions when they occur, check whether they occurred on the previous bar, so you can easily tell whether the price and MA kept rising or not.

    #210044 quote
    miric94
    Participant
    New

    Hm! I think I understand and sounds like a good idea, does anybody have an example?

    I know you do a lot on the forums Roberto, super thankful for all your help and insights.

    #210060 quote
    robertogozzi
    Moderator
    Master

    Instead of:

    IF high >= MyLine AND MA1 <= MyLine  THEN
       //wait to see what happens next...
    ENDIF

    write:

    IF high[1] >= MyLine[1] AND MA1[1] <= MyLine[1]  THEN //if the previous bar my conditions had met
       IF high <= high[1] AND MA <= MA[1] THEN            //go ahead if both the price and MA have not kept rising
          //
          // do whatever you want to do, here
          //
       ENDIF
    ENDIF
    miric94 thanked this post
    #210176 quote
    miric94
    Participant
    New

    Wow. In hindsight that was really simple.

    Thanks a lot, will play around with this new-found knowledge!

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

Measure MA on the next bar


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
miric94 @miric94 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by miric94
2 years, 12 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/20/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...