Code help needed. Thanks


I am a novice compared to most of you awesome guys here. I wonder if the following is possible and if yes, would greatly appreciate help coding it

Let's say this is my buy/sell code based on some crossovers defined:

Buy = Cross(MA1, MA2);
Sell = Cross(MA2, MA1);

Short = Cross(MA2, MA1);
Cover = Cross(MA1, MA2);

Now, I would like the buy sell to work as per the following modifications:

.Do not generate multiple buy/sell signals on one candle. This means a max of 1 buy or one sell signal on one candle is possible.

.buy or sell on current bar if defined MA crossover has happened and if 50% retracement of current bar's price change would still result in the defined MA crossover and in that case, generate buy/sell signal at the current price +'x%' for buy and current price +'x%' for sell ('x' can be a positive or negative value)

else (which means that if 50% retracement of current bar would remove the defined crossover, then wait for the bar to be completed) and if the crossover has happened on the current bar, buy / sell on the next bar at open price +'x%' for buy and next bar open price +'x%' for sell ('x' can be a positive or negative value)

.After the buy/sell signal as above is generated, generate a reverse signal, if

stop loss of 'x%' is hit, or
if stock goes in profit by higher than 'x%', activate trailing stop loss of 'x%' of profit.



See How to use this site.

I checked the link but don't know what exactly you meant.

Are you sure about that??? (at the time of writing the link has not been clicked!).

I see the link is only now been clicked!

Read the link again - you need to use Code Blocks as per forum rules.

I thought you said you read the link???

can someone tell me if this code is good to be deploed in auto trading or what are the issues I need to address.

It's probably best you determine that...

Read it again - please follow forum rules!

I don't know coding but somehow put this together.

Is that right???

well that was 10 seconds of my life I'll never get back, LOL

1 Like