SMA Cross Previous Occurrence Price

 

I am trying to capture Price from the Previous SMA cross and use it as a variable. 

I know how to program to test WHEN it crosses.  I am aiming for the exact price.  Anyone able to help here?

 
Brian Farnell:I am aiming for the exact price.  Anyone able to help here?
  1. Do your algebra.
    F(x)=iMA(…, x)
    S(x)=iMA(…, x)
    Mf=F(2)-F(1)                       Slope
    Ms=S(2)-S(1)
    Price = Mf x + F(1)= Ms x + S(1)   P= Mx+b
    
    Solve for x

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

 
William Roeder:
  1. Do your algebra.

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

Seriously?  This is my first post here and I'm relatively new to MQL4.  I'm watching tutorials, learning the basics, coming up with ideas and I've hit a wall where tutorials don't offer direct assistance.  I am asking for help, not demanding it or saying it's urgent.  I've stated my problem, perhaps not at succinctly as you'd like, but you're not the only person here, so kindly ease up on the high and mighty throttle, champ.  Teach with a students mind or save your breath.
 
Brian Farnell:

Please do not place your reply inside the quote. I have edited your post to move your reply outside the quote box.

 
Brian Farnell:

I am trying to capture Price from the Previous SMA cross and use it as a variable. 

I know how to program to test WHEN it crosses.  I am aiming for the exact price.  Anyone able to help here?

How do you test for a cross without getting the prices at the time of the cross?

 
Keith Watford:

How do you test for a cross without getting the prices at the time of the cross?

I am using a simple (I'm pretty sure)formula (code excerpt):

//------------------------------------------------------------------+

// CONFLUENCE SMA SELL SIGNAL

//------------------------------------------------------------------+

   if((LastFastMovingAverage > LastSlowMovingAverage)

      &&(FastMovingAverage < SlowMovingAverage))

     {

      SMASell = TRUE;      

     }  

//------------------------------------------------------------------+

// CONFLUENCE SMA BUY SIGNAL

//------------------------------------------------------------------+

   if((LastFastMovingAverage < LastSlowMovingAverage)

      &&(FastMovingAverage > SlowMovingAverage))

     {

      SMABuy = TRUE;      

     }

My root goal is this.  I want to back test for the LAST SMA cross and then set that as the next TP for a trade.  So, I don't need the current SMA cross, as that is a confluence signal I am using to enter the trade.  I am learning about Array's, but I continue to see "Old(tradesignalhere)" versus current or "Last(tradesignalhere)" versus current.  So, the question is not so much a show me how to do it as much as it is- Is there a MQL4 function that delivers this information? 

I did learn about shift's in the parameter set of a function call between yesterday and today.  So, I believe with a loop and some code trial-and-error I can create a for-loop that will back test to the last cross then provide me that price.  

Just learning mind you.  New guy, rookie code, YouTube and trial and error.  I'm a PLC programmer by trade so I am familiar with coding, just not C++.  I don't want to pay  someone for something I totally have the patience to learn on my own.