Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

predict MA value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    predict MA value

    I trade crossovers and currently dont have stops. I would prefer to have a stop at the broker so that i am safe.
    how can i predict a MA value. ie how can i can i calculate how far the price should move next bar for me to have a crossover again.

    I use a 20 ema and 9 ema crossovers for trading.
    any suggestions for logic is appreciated.

    #2
    Originally posted by junkone View Post
    I trade crossovers and currently dont have stops. I would prefer to have a stop at the broker so that i am safe.
    how can i predict a MA value. ie how can i can i calculate how far the price should move next bar for me to have a crossover again.

    I use a 20 ema and 9 ema crossovers for trading.
    any suggestions for logic is appreciated.
    You simply need to determine the value of CloseNext that will make the EMA(9) equal the EMA(20). Depending on whether you are looking at a cross-below or a cross-above, exceeding that value in the correct direction will determine if a cross occurs. The correct direction will be determined by whether the predicted value is greater or less than the current close.

    Code:
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private double[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] EMA9SamplingFactor = [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]/[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]10[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private double[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] EMA20SamplingFactor = [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]/[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]21[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    Code:
    [FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000]// Equate the 2 EMA expressions, and solve for CloseNext.[/COLOR][/FONT]
    [/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]double[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] CloseNext = (([/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] - EMA20SamplingFactor) * EMA([/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]20[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New])[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] - ([/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] - EMA9SamplingFactor) * EMA([/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]9[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New])[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]]) / (EMA9SamplingFactor - EMA20SamplingFactor);[/FONT]

    Comment


      #3
      Thank you very much Koganam for your help. Can you explain the logic so i can understand it.

      Comment


        #4
        Originally posted by junkone View Post
        Thank you very much Koganam for your help. Can you explain the logic so i can understand it.
        Not sure what you want me to explain. Ultimately, it is simply a resolution of 2 simultaneous equations, with 2 unknowns, where both equations are derived from the same structure of an infinite response filter, with differing initial conditions.

        As I said in the initial response: "You simply need to determine the value of CloseNext that will make the EMA(9) equal the EMA(20)."

        Maybe if you asked a more focused question, I might be able to better respond?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        80 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        46 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        29 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        32 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        66 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X