Hi,
I have defined an EA based on price action in Pips from a moving average and my very amateur coding is giving inconsistent entries and exits. The EA attempts to get in on trends as they begin and exit with a Trailing stop and/or Take profit, or if the breakout fades.
I was wondering if anyone could help code it and of course you would be free to use it as well, if it performs to your liking.
The EA would have several user defined variables based on a current MA so that it could be used and tested over a variety of markets and time frames. Here are the details of the EA...
Trade options:
Trailing Stop (TS): True or False
Take Profit (TP): True or False
Variables (six variables):
Var 1: Current Price
Var 2: Current Simple Moving Average (SMA) where SMA length would be user defined.
Var 3: UpTrend Confirm, which would be current SMA plus an X number of pips where X is user defined.
Var 4: DownTrend Confirm, which would be current SMA minus an X number of pips where X is user defined.
Var 5: ExitBuy Signal, which would be current SMA minus an X number of pips where X is user defined.
Var 6: ExitSell Signal, which would be current SMA plus an X number of pips where X is user defined.
Rules:
Buy when Var 1 > Var 3, and
when Close [0] > Close [1], and Close [1] > Close [2].
Sell when Var 1 < Var 4 and
when Close [0] < Close [1], and Close [1] < Close [2].
Only one trade at a time.
Exit:
Exit a buy when Var 1 < Var 5, or if Trailing Stop or
when Take Profit is "True" and triggered.
Exit a sell when Var 1 > Var 6, or if Trailing Stop or
when Take Profit is "True" and triggered.
Thank you
I have defined an EA based on price action in Pips from a moving average and my very amateur coding is giving inconsistent entries and exits. The EA attempts to get in on trends as they begin and exit with a Trailing stop and/or Take profit, or if the breakout fades.
I was wondering if anyone could help code it and of course you would be free to use it as well, if it performs to your liking.
The EA would have several user defined variables based on a current MA so that it could be used and tested over a variety of markets and time frames. Here are the details of the EA...
Trade options:
Trailing Stop (TS): True or False
Take Profit (TP): True or False
Variables (six variables):
Var 1: Current Price
Var 2: Current Simple Moving Average (SMA) where SMA length would be user defined.
Var 3: UpTrend Confirm, which would be current SMA plus an X number of pips where X is user defined.
Var 4: DownTrend Confirm, which would be current SMA minus an X number of pips where X is user defined.
Var 5: ExitBuy Signal, which would be current SMA minus an X number of pips where X is user defined.
Var 6: ExitSell Signal, which would be current SMA plus an X number of pips where X is user defined.
Rules:
Buy when Var 1 > Var 3, and
when Close [0] > Close [1], and Close [1] > Close [2].
Sell when Var 1 < Var 4 and
when Close [0] < Close [1], and Close [1] < Close [2].
Only one trade at a time.
Exit:
Exit a buy when Var 1 < Var 5, or if Trailing Stop or
when Take Profit is "True" and triggered.
Exit a sell when Var 1 > Var 6, or if Trailing Stop or
when Take Profit is "True" and triggered.
Thank you