Login Page - Create Account

Support Board


Date/Time: Sat, 01 Mar 2025 14:24:45 +0000



[Programming Help] - How do a Crossover Trading system?

View Count: 1596

[2021-10-03 02:25:16]
hr719 - Posts: 25
Currently I am using a Moving Average Crossover study. So I am trying to use the trading system bases on alert cross over, but not sure what to put in the "alert condition section." Basically I want the conditions to be:


If above 50 EMA, When the bar closes above 9 EMA, Go long. Only sell this contract once the bar closes belove 9EMA.

If the below the 50 EMA. Sell once the bar closes below 9 ema, and close contract once the bar closes above 9 EMA.

Basically I only want to go long when its above 50 EMA with 9Ema cross as the alert to buy and close contract. I dont ever want to go short above 50 ema, and I dont ever want to go long under 50 ema.

Can someone please help me on what to put on Alert Conditions to achieve this?
[2021-10-03 22:51:11]
Sawtooth - Posts: 4178
Try this, where the Moving Average Crossover study is ID1:

Buy entry:
=AND(ID1.SG3>0,C>ID1.SG1)
Buy exit:
=C<ID1.SG1

Sell entry:
=AND(ID1.SG4>0,C<ID1.SG2)
Sell exit:
=C>ID1.SG1

Study/Chart Alerts And Scanning
Trading System Based on Alert Condition
Date Time Of Last Edit: 2021-10-03 22:59:43
[2021-10-03 23:58:47]
hr719 - Posts: 25
Hey, thank you for those formulas.It seems to work good, but its not taking all the orders from from the 9 EMA.It seems to only take the first order, I would like it if could take a buy order every tike it crosses from below the 9 ema, as long as its above the 50 eMA. So say if there is a small sell off the price will cross below the 9 EMA, but if its still above The 50 EMA,it should take the buy signal when it crosses from below the 9 EMA. I hope im making sense. When i tested th above formuLA, it onlu boUGHT The cross omce, but the price crossed through the 9 mULTIple times with no order placed.
[2021-10-04 03:11:22]
Sawtooth - Posts: 4178
Are you saying the signals are not the 9 EMA crossing the 50 EMA, but the bar's close crossing the 9 EMA (with the direction of trade based on the EMA stack)?

Observation: The 9 EMA is a fast MA and is always near the price bar. You will have many whipsaw trades because the exits are also at the 9 EMA.

Please confirm.
[2021-10-04 03:25:06]
hr719 - Posts: 25
corrext! when above the 50 ema, i want to take long trades only. once above, i want to use 9 as the order placer and the price crossing between it. once under 50 ema i want only sell orders based on the 9 ema for selll triggers.

yes i understand its very close, but im testing a method and results have been good. i have my own brackets set so i dont even use buy exit much its just there for safety.
[2021-10-04 11:55:48]
Sawtooth - Posts: 4178
Try this, where the Moving Average Crossover study is ID1:

Buy entry:
=AND(ID1.SG1>ID1.SG2,CROSSFROMBELOW(C,ID1.SG1))
Buy exit:
=C<ID1.SG1

Sell entry:
=AND(ID1.SG1<ID1.SG2,CROSSFROMABOVE(C,ID1.SG1)
Sell exit:
=C>ID1.SG1

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account