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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        64 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X