Buy when Close crosses above EMA of (Close,7) at Buyprice of Ref(EMA(Close,7),-1).
Buy = Cross((Close),(EMA(Close,7)));//when Close crosses above EMA of (Close,7)
Prevday EMA = Ref(EMA(Close,7),-1);
Sell =.................
Assume Close crosses above EMA of (Close,7) and at that time buyprice is 1000. The expectation is buyprice will go down further upto 995 which is
equal to Previous day EMA. I would like to buy at buyprice 995. Could you please help me to build coding for it?
@av.ragavan I think you are looking to place a Limit Order. You need to review this Knowledge Base article and identify the price you are looking to enter at.
I have corrected it now, please check the code below and let me know If I miss anything.
Assume Close crosses above EMA of (Close,7) and at that time buyprice is 1000. The expectation is buyprice will go down further upto 995 which is
equal to (Previous day EMA - (0.005*Previous day EMA)). Buy on next days Open or Buylimitprice whichever is minimum.
@av.ragavan Did you make an attempt to debug your code? Have you run a backtest and examined the detailed log? Let us see those results? Have you coded an Exploration and looked at the signals and prices? Are they the results that you expected? If not, what was different? I have not done that for you so I am not certain what the answer to your question is.
I doubt that you have done all of the above because you have not even read the 5 lines of code that I first referenced. You must carefully read the Knowledge Base article. Slowly, carefully. Why did you not include this line?
// buy on the next bar
Buy = Ref( BuySignal, -1);
It does not appear to me that you are making any serious effort at solving your problem and learning how to use AmiBroker.
Good luck, perhaps someone else will hold your hand and write all of your code for you.