Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hopefully this is a simple task that I am just too stupid to grasp at the moment, but here goes:
If I want to trade based on an indicator (just say a moving average or something), and I want to buy at some point below the average. However, I want to wait until the price moves above the average, and at this time I would like to set this same average to be my exit condition to the downside.
So, train of thought would be:
1. Go long at Point A below moving average
2. Wait until Close[0] is above the moving average
3. Exit Long when Close[0] crosses back below the moving average
I tried coding it sort of like this, but it doesn't work at all.
Can anyone provide some help on this? I know it's convoluted, but I'd at least like to learn how to code this (for educational purposes if nothing else!)
Thanks,
Jordis
Can you help answer these questions from other members on NexusFi?
Hopefully this is a simple task that I am just too stupid to grasp at the moment, but here goes:
If I want to trade based on an indicator (just say a moving average or something), and I want to buy at some point below the average. However, I want to wait until the price moves above the average, and at this time I would like to set this same average to be my exit condition to the downside.
So, train of thought would be:
1. Go long at Point A below moving average
2. Wait until Close[0] is above the moving average
3. Exit Long when Close[0] crosses back below the moving average
I tried coding it sort of like this, but it doesn't work at all.
if (Positions[0].MarketPosition == MarketPosition.Long)
{
if (Close[0] > MovingAverage)
if(CrossBelow(EMA(1), MovingAverage), 1))
{
ExitLong("c"+Time[-1], "long");
}
}
Can anyone provide some help on this? I know it's convoluted, but I'd at least like to learn how to code this (for educational purposes if nothing else!)
Thanks,
Jordis
How about something like this...I hope I interpreted your rule correctly.
if (Close[0] < MovingAverage[0]) EnterLong();
if (Close[0] < MovingAverage[0] && High[0] >= MovingAverage[0]) ExitLong();