hi
What would the code look like for having long entries only when above 50 period mov avg and short entries when below 50 period mov avg.
I am migrating from a different platform and also I am not the sharpest tool in the shed.
thanks
shane
mov avg question
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: mov avg question
Hello Shane,
Have you tried using the prebuilt signals MovAvg Cross LE and MovAvg Cross SE with Length input = 50 ?
Have you tried using the prebuilt signals MovAvg Cross LE and MovAvg Cross SE with Length input = 50 ?
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
Re: mov avg question
hi henry
yes, they do form the basis for the strategy. I just wanted to set up a scenario where only the
mov avg LE and SE are used when price is above the 50 period MA. In other words, the 15 period Mov Avg LE is triggered when price is above the 50 period MA. Does it make sense ?
thank you
shane
yes, they do form the basis for the strategy. I just wanted to set up a scenario where only the
mov avg LE and SE are used when price is above the 50 period MA. In other words, the 15 period Mov Avg LE is triggered when price is above the 50 period MA. Does it make sense ?
thank you
shane
- ABC
- Posts: 718
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 408 times
- Contact:
Re: mov avg question
Hi shanemcdonald,
this is the condition for the price being above the average, taken from the "MovAvg Cross LE" signal.
Let's assume your length is 15, what about simply adding another part to the condition:
In case you want two conditions for your strategy to add to other entries, do something like this:
This should get you going.
Regards,
ABC
this is the condition for the price being above the average, taken from the "MovAvg Cross LE" signal.
Code: Select all
condition1 = Price > AverageFC( Price, Length ) ;
Code: Select all
condition1 = Price > AverageFC( Price, Length ) [b]and Price > AverageFC(Price, 50)[/b];
Code: Select all
inputs: Price( Close ), Length( 50 );
Variables: MovAvg(0), AboveMA(false), BelowMA(false);
MovAvg = AverageFC(Price, Length);
//reset the flags
AboveMA = false;
BelowMA = false;
//check if Price is above the MA
AboveMA = AboveMA or (Price > MovAvg);
//check if Price is below the MA
BelowMA = BelowMA or (Price < MovAvg);
//now you can use these two flags together with your other entry conditions
if MyLongCondition1 and MyLongCondition2 .... and AboveMA then
Buy ("Long") next bar market;
Regards,
ABC
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
Re: mov avg question
hi
thanks ABC
that will help
switching over to MC is tricky for me
also, I am using the SE .net version and I posted in the wrong forum ! haha lol
sorry about that
take care
shane
thanks ABC
that will help
switching over to MC is tricky for me
also, I am using the SE .net version and I posted in the wrong forum ! haha lol
sorry about that
take care
shane