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 kaywai, Today, 06:26 AM
        1 response
        5 views
        0 likes
        Last Post kaywai
        by kaywai
         
        Started by ct, 05-07-2023, 12:31 PM
        6 responses
        203 views
        0 likes
        Last Post wisconsinpat  
        Started by kevinenergy, 02-17-2023, 12:42 PM
        118 responses
        2,780 views
        1 like
        Last Post kevinenergy  
        Started by briansaul, Today, 05:31 AM
        0 responses
        10 views
        0 likes
        Last Post briansaul  
        Started by traderqz, Yesterday, 12:06 AM
        11 responses
        28 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X