"Three days before MA(18) and MA(48) cross each other" - AmiBroker | futures io social day trading
futures io futures trading


"Three days before MA(18) and MA(48) cross each other"
Updated: Views / Replies:483 / 5
Created: by alexb1995 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

"Three days before MA(18) and MA(48) cross each other"

  #1 (permalink)
Trading Apprentice
Ludwigshafen am Rhein
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Emini ES
 
Posts: 4 since Jan 2017
Thanks: 0 given, 0 received

"Three days before MA(18) and MA(48) cross each other"

Hi,

I'm pretty new to AFL and have the following issue, where two conditions need to be true to return a buy signal:
I'd like to express that if a 48 days average and an 18 days average cross each other, plus the 18 days average is at the day of the crossing higher than 3 days before, it should give me a buy signal.

I tried the following:
 
Code
period1 = MA(Close, 48);
period2 = MA(Close, 18);

crossing = Cross(period2, period1);
rising = Ref(period2, crossing) > Ref(period2, Ref(crossing, -3)); //Close at Day of crossing > 3 days before

buy = crossing and rising;
Unfortunately this doesn't work, i guess it is because Cross() simply gives out 0 or 1 (false/true) for each day, and not a date, so it's not possible to use Ref() on its result.


I hope my concern is understandable and it would help me a lot if anybody has a tipp.

Thank you!

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received


alexb1995 View Post
Hi,

I'm pretty new to AFL and have the following issue, where two conditions need to be true to return a buy signal:
I'd like to express that if a 48 days average and an 18 days average cross each other, plus the 18 days average is at the day of the crossing higher than 3 days before, it should give me a buy signal.

I tried the following:
 
Code
period1 = MA(Close, 48);
period2 = MA(Close, 18);

crossing = Cross(period2, period1);
rising = Ref(period2, crossing) > Ref(period2, Ref(crossing, -3)); //Close at Day of crossing > 3 days before

buy = crossing and rising;
Unfortunately this doesn't work, i guess it is because Cross() simply gives out 0 or 1 (false/true) for each day, and not a date, so it's not possible to use Ref() on its result.


I hope my concern is understandable and it would help me a lot if anybody has a tipp.

Thank you!

your concern is a bit ambiguous. but as far as i got it, you can try this:

MA1 = MA(C, 48);
MA2 = MA(C, 18);

Buy = Cross(MA2, MA1) AND Close > Ref(Close, -3);

and please read the amibroker guide and understand the basics of afl coding. amibroker doesn't backtests the program without buy, short, sell and cover conditions. all 4 are required.

Reply With Quote
 
  #3 (permalink)
Trading Apprentice
Ludwigshafen am Rhein
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Emini ES
 
Posts: 4 since Jan 2017
Thanks: 0 given, 0 received


Thank you for your answer!

Since English is not my first language, I am giving my best to express myself clearly, so sorry for any misunderstanding.


 
Code
Buy	=	Cross(MA2, MA1) AND Close > Ref(Close, -3);
Doesn't Ref(Close, -3) refer to the closing price three days ago? (as I red on the amibroker online guide)

What I want is to compare the closing price of the day where MA and MA2 cross, with the closing price three days before the crossing.
Won't your code compare the closing price of the crossing with the closing price three days starting from today?


Thank you!

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received


alexb1995 View Post

Won't your code compare the closing price of the crossing with the closing price three days starting from today?


Thank you!

as i said, i didn't exactly get what you wanted, that's why the error. English is not my first language too.

MA1 = MA(C, 48);
MA2 = MA(C, 18);

Crossing = ValueWhen(Cross(MA2, MA1), Close, 1);
Rising = IIf(ValueWhen(Crossing,Close,1) > Ref(Close, -3), 1, 0);

Buy = Cross(MA2, MA1) AND Rising;

now, i am not an expert at coding, so i am not sure about the reference to close of 3 candles previous to Crossing, but i think the above code should do it.

if it doesn't, check this link https://www.amibroker.com/guide/afl/valuewhen.html

from what i know, what you want can be accomplished by the ValueWhen function.

Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Ludwigshafen am Rhein
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Emini ES
 
Posts: 4 since Jan 2017
Thanks: 0 given, 0 received

Okay good, I guess you got it now

Your code looks good I didn't knew the ValueWhen() Function. I'm gonna try it.

Thank you very much!

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received

ignore the earlier one. it should be :

MA1 = MA(C, 48);
MA2 = MA(C, 18);

Crossing = ValueWhen(Cross(MA2, MA1), Close, 1);
Rising = IIf(ValueWhen(Crossing,Close,1) > Ref(Close, -3), 1, 0);

Buy = Cross(MA2, MA1) AND Rising == 1;

hope it works. good luck!

Reply With Quote

Reply



futures io > > > > "Three days before MA(18) and MA(48) cross each other"

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
MA cross with bar paint Michael Krall NinjaTrader 9 December 6th, 2017 09:34 AM
Price MA cross help Please tickvix NinjaTrader 2 February 28th, 2012 12:41 PM
Multi Timeframe MA cross Strategy ryangillespie The Elite Circle 1 December 8th, 2011 06:31 PM
Trying to find a MA with cross alert blkreign69 NinjaTrader 18 October 8th, 2011 11:15 PM
MA cross Buy/Sell Strategy - need help SPMCC NinjaTrader Programming 11 January 31st, 2010 07:16 PM


All times are GMT -4. The time now is 07:03 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-13 in 0.10 seconds with 19 queries on phoenix via your IP 54.90.92.204